Friday, November 21, 2014

Validation of viewstate MAC failed when posting from one aspx file to another (cross posting asp.net forms)

The error
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.


We have a aspx form that posts to another form. This was done by changing form action for the first form to point to the second form. When this happens, asp.net was giving the above error.

As a solution, the submit button on the form was also changed to update the postbackURL to point to the second aspx page. So essentially, the form action and also the submit button postback URL were both pointed to the second aspz page where the form data is submitted!

Example:
this.Form.Action = "MyPage2.aspx";
SubmitButtonCtl.PostBackUrl = "MyPage2.aspx";

Friday, November 7, 2014

How to Mirror or Sync entire directory and subdirectories with all files included using robocopy in windows

Windows comes with a nice command line tool called robocopy. Use the below command to sync up two folders.

robocopy dirA DirB\ /MIR /W:5

where DirA is the source folder and DirB is the destination folder. If DirB do not exist, it will create one for you. If it already exist, it will check every item in Destination folder DirB and its sub-folders and make sure it mirrors the source directory DirA and its sub-folders. It deletes extra files or copies over new or updated files to complete this task.


Internet Information Services 8.5, Windows server 2012 R2, asp.net 4.5.1 error "The resource cannot be found."


After configuring my application in IIS, I was continuously getting this error "The resource cannot be found." while requesting any aspx files. Images and html files were opening just fine


Server Error in '/' Application.
The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /myapp/Index.aspx


It turned out that I have created the website and pointed the folder as f:
ie; the in the site, the physical path was pointing to f:
It started working after I changed f: to f:\

I didn't care about this as nobody was supposed to access the site directly; they all will go to a sub application folder. I had then proceeded to create my application myapp under this site and copy all the application files over. Unfortunately, the application refused to execute any aspx code with this odd error "The resource cannot be found." in any subfolders (sub applications under main site) until I fixed the path of the main site as f:\


HTTP Error 500.24 - Internal Server Error ASP.net 4

HTTP Error 500.24 - Internal Server Error

An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.

Most likely causes:

  • system.web/identity@impersonate is set to true.

Things you can try:

  • If the application supports it, disable client impersonation.
  • If you are certain that it is OK to ignore this error, it can be disabled by setting system.webServer/validation@validateIntegratedModeConfiguration to false.
  • Move this application to an application pool using Classic .NET mode - for example, %SystemRoot%\system32\inetsrv\appcmd set app "Default Web Site/" /applicationPool:"Classic .NET AppPool"
(You can set "Classic .NET AppPool" to the name of another application pool running in Classic managed pipeline mode)

Detailed Error Information:

Module   ConfigurationValidationModule
Notification   BeginRequest
Handler   StaticFile
Error Code   0x80070032
Requested URL   https://localhost:443/images/welcome/login2.jpg
Physical Path   C:\images\welcome\login2.jpg
Logon Method   Not yet determined
Logon User   Not yet determined

More Information:

If you are not sure or unable to use the first two options, then it is preferred that you move this application to Classic mode. View more information »


It started working once I changed from
<identity impersonate="true" /> to <identity impersonate="false" /> in file : C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config

Windows Server 2012 R2, Internet explorer 11 (IE) not able to browse https (SSL secured) sites

Not sure why this is, but the only way it started working was by unchecking option “warn if changing between secure and nonsecure mode” in  Internet explorer 11 (IE) advanced settings. Once done, was able to browse any https sites.

It was really odd this has to be done so https sites can be browsed. Before the change, if you try to navigate via https, the browser will act as if it was not clicked or accessed. I had Internet Explorer Enhanced Security Configuration enabled, so not sure if this has anything to do with the problem

Turn on Windows 11 Fast Boot

If windows starting is slow, to enable windows 11 fast startup/boot,  Press Windows + R, type powercfg.cpl, and hit Enter.  This will direct...