Server Error - Upgrading Existing ASP.Net 2.0 Web site to ASP.Net 4.0

by Naveen 24. May 2010 10:09

Recently I was working on upgrading this site to from ASP.Net 2.0 to ASP.Net 4.0. As a first quick pass, I followed my usual procedure of loading the projects into Visual Studio 2010 and set the target for all projects to use .Net 4.0 framework. So far so good. I tested it on my development machine which is Windows 7 and everything worked as I expected.

So I went ahead with deployment on my production Windows server. I changed the target ASP.Net framrwork of my web site to ASP.Net 4.0 from ASP.Net 2.0. And site loaded and started serving requests. After few hours I got an email from another site owner who is hosting site on my server that all sites have stopped working and we were getting Server Error or Application Error. I have about dozen sites hosted on the server and all but one stopped working. Only one that was working was this site that I just upgraded to use ASP.Net 4.0. Right there I realized the mistake I made. This is the samee mistake that was made when sites were upgraded from ASP.Net 1.1 to ASP.Net 2.0.

Mixed ASP.Net versions in Application Pool

Yes, now I had one site in the application pool that was using ASP.Net 4.0 and others were using ASP.Net 2.0. Application pools do not allow mixed version of .Net framework. Here are some things that you will have to take into consideration when migrating your existing ASP.Net sites from 2.0 t0 4.0 or when adding new sites on Windows 2003 server.

  • Make sure that you do not mix use of ASP.Net version in same pool
  • Best option is to make a new Application Pool and put your new or migrated ASP.Net 4.0 sites in there.
  • If you have already made a mistake (like I did) of mixing ASP.Net versions on application pool, then there are few options you can use:
    • Move the sites using ASP.Net 4.0 framework to a new pool or move ASP.Net 2.0 sites into new pool depending on whatever is less work.
    • I have run into cases where moving ASP.Net 4.0 out of pool did not work. If upgrading all sites to ASP.Net4.0 framework is not going to break anything, then you may have to consider that option.
    • When you start upgrading existing sites to use new pool or upgrade to new ASP.Net 4.0 you may run into problem that all sites start showing Service Unavailable error. This has been happening a lot on Windows 2003 server. During process of upgrading and pool switching, some time IIS stops working. You will notice a red cross mark on Web Sites node in IIS. You will have to goto Service Control Manager to restart worldwide web publishing service on your server

I hope this little piece of information helps you get out of problem of upgrading existing site to ASP.Net 4.0 when there are other sites in same pool that use older version of ASP.Net.

Views: 505

Tags: ,

ASP.Net | IIS

How to fix Security Error When Installing DNN On Windows 7

by Naveen 31. March 2010 04:48

When you install DotNetNuke (in my case it was latest 5.3.1 release), you may run into the following exception and error when you try to launch the wizard for fresh install. This error can actually occur even after you have configured your DNN site correctly.


Server Error in '/DNN53' Application.
-------------------------------------

Security Exception
Description: The application attempted to perform an operation not allowed by
the security policy.  To grant this application the required permission please
contact your system administrator or change the application's trust level in 
the configuration file.

Exception Details:
System.Security.SecurityException: Request for the permission of type 
'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' failed

The issue here is related how you created and configured your virtual directory or web application in IIS7 or higher. When creating a virtual directory in IIS on Windows 7, the default setting make use of DefaultAppPool. And that pool is configured to use Integrated Pipe Line as shown in the following screenshot. DNN framework does not seem to be configured and implemented to handle this integrated IIS pipeline and ends up throwing security exception. The simple fix is to switch your application pool to use Classic .Net AppPool or if you have some other custom application pool that does not use Integrated pipe line.

Views: 1152

Tags: , , ,

DotNetNuke | IIS | Windows 7

HTTP Error 404.17 - Not Found, The requested content appears to be script and will not be served by the static file handler

by Naveen 25. March 2010 05:04

If you are developing on Windows 7 or Vista or for that matter operating system where you have IIS7 installed and have Visual Studio 2008 and Visual Studio 2010 installed, at some point you will run into following error when developing WCF service.


HTTP Error 404.17 - Not Found
The requested content appears to be script and will not be served by 
the static file handler.

You do not receive this error because you have one of the components mentioned above installed or because of the operating system. It is combination of few things that causes this error. I read few posts about this error and could not find a comprehensive explanation and solution. I had to stich together few of those suggestions to come up with final solution and explanation. In this post I will make an attempt to discuss how to diagnose this error, why this occurs and how to fix it.

Diagnosis

One thing that IIS7 does very well is that error descriptions have become little bit more descriptive as compared to previous versions. So if you look at the error, it tells that it something to with file handler for the file type that user is trying to access. In my case I have a WCF service so my file is .svc

Requested URL: http://localhost:80/ProductsSearch/AmazonSearchService.svc 

That was kind of strange to me that I had developed a similar application and WCF service using Visual Studio 2010 and did not get this error. But this time I was developing on Visual Studio 2008. So there was first clue that it has something to do with version of some component. Follow the following steps to see what file handler or mime type handlers are installed for your web site.

  • Bring up IIS manager and you will notice an icon in IIS section that reads Handler Mappings.

  • Double click on this icon and you will see a dialog box that looks like image belong and has listing of all file types and the handlers associated with it. Locate the file type that is throwing error for you. In my case it was .svc file for WCF service. I noticed that there are three file handlers associated with this file type and I am still getting the error.

  • Double click on any of these entries and you will see the details that look like image below. It tells you the assembly or module that is mapped to handle requests for these file types. You will notice that in my case it was pointing to correct ISAPI extension BUT it was pointing to .Net 4.0 framework folder.

The last step made things clear that although I have a file handler for .svc file type, but it is being served by framework version for which my site is not configured. I was developing for ASP.Net 2.0. The solution was just to have correct mapping for correct .Net framework that my web site is mapped to.

Finding Mapped Framework For Your Web Site

Each application in IIS7 is configured to use an application pool. And each of these application pools is assigned to a .Net Framework. When you create an application in IIS7 is gets assigned to Default Application Pool by default untill you change it explicitly. And depending on you have configured application pools, this Default Application Pool may be mapped to ASP.Net2.0 or ASP.Net4.0 depending on what all versions of ASP.Net framework you have installed on your machine. In my case Default Application Pool is mapped to .Net 2.0 framework as you can see from the screenshot below.

Default Application Pool

Fix The Error

There are two steps that you will have to perform the error about mapping to static file handler.

Fix Application Pool

Check the application pool for your application. Make sure that it is configured to correct version of .Net framework. You can always a custom application pool in IIS and then configure your application to use that. You can always configure your application to use Classic .Net AppPool. You can see from following screenshot that it is mapped to .Net 2.0 and configured to use Classic pipe line and not integrated one.

Add or Edit Mapping

There is a good chance that your installation of IIS7 does not have mapping for the file type for .Net framework version that your application is using. Follow the following steps to add a new mapping in IIS for your application.

  • Bring up Mapping Handler dialog box for your web application.

  • In right side pane you will notice a link Add Script Map.

  • Click on that link that will bring up Add Script Map dialog box. Enter the required information to create a new mapping. Pay close attention to the handler module file path. Notice that I have created a new mapping for .svc file that is going to be served by aspnet_isapi.dll from v2.0.50727 folder and not from .Net 4.0 folder.

  • Click OK and you should have new file handler added for your application.

This should fix the error.

Views: 2602

Tags: ,

IIS | WCF

Unable to start debugging on the web server - Error when starting ASP.Net debugging

by Viper 1. October 2009 13:59

Recently I installed Visual Studio 2010 and was working on a prototype User Activity Monitoring administration application. When I tried to launch the application in Visual Studio IDE, I got the following error message box.

---------------------------
Microsoft Visual Studio
---------------------------
Unable to start debugging on the web server. Debugging failed because integrated 
Windows authentication is not enabled. Please see Help for assistance.
---------------------------
OK   Help   
---------------------------

As the error suggests that I need to enable windows authentication. And that is a pre-requisites for running ASP.Net application under debugger. But thing that was different is that till Visual Studio 2008 when you made the IDE to create Virtual Directory, it used to enable windows authentication in IIS for that virtual directory. It seems that Visual Studio 2010 does things differently. It only enables anonymous access. You will have to explicitly enable windows authentication. It is simple procedure.

  • Launch IIS manager
  • Right click on virtual directory and select Properties menu option
  • Select Directory Security tab on the dialog box.
  • On this view click on Edit button in Anonymous access and authentication control section at top
  • On this dialog box, check the check box at the bottom in front of Integrated Windows Authentication option.
  • Click OK and apply your changes.

Views: 2241

Tags: ,

ASP.Net | IIS | Visual Studio

ASP.Net version getting set to 4.0 in IIS manager

by Viper 6. August 2009 05:26

I have been working with VS2010 and ASP.Net 4.0 for quite some time now. Every time i create a web application, I just use the handy feature of Visual Studio of creating virtual directory for web application. Last week I was manually creating virtual directory for a web application using IIS manager. Since the application was targeting ASP.Net 2.0, so from ASP.Net tab of IIS, I selected V2.0 framework. Now there is a confirmation dialog box that comes up when you change ASP.Net framework.

Changing the Framework version requires a restart of the W3SVC service. Alternatively, you can change the Framework version without restarting the W3SVC service by running: aspnet_regiis.exe -norestart -s IIS-Viirtual-Path Do you want to continue (this will change the Framework version and restart the W3SVC service)?

Everything is good so far. Moment i accessed the application in browser, I got the following error message.

Server Error in '/Foo' Application.
The application domain or application pool is currently running version 4.0 or later of the .NET Framework. This can occur if IIS settings have been set to 4.0 or later for this Web application, or if you are using version 4.0 or later of the ASP.NET Web Development Server. The <compilation> element in the Web.config file for this Web application does not contain the required 'targetFrameworkMoniker' attribute for this version of the .NET Framework (for example, '<compilation targetFrameworkMoniker=".NETFramework,Version=v4.0">'). Update the Web.config file with this attribute, or configure the Web application to use a different version of the .NET Framework.

I was little surprised because I never configured virtual directory for this application to use ASP.Net 4.0. I fired up IIS manager and went to ASP.Net tab. There it was, the application was configured to use ASP.Net 4.0. So I changed it back to use ASP.Net 2.0. Accessed the application in browser and got the same error again. I experimented with the drop down box for ASP.Net version in IIS manager. The application will get configured to use ASP.Net 4.0 no matter what option I picked from the drop down box. It seems that this is some bug in beta version of Visual Studio 2010 installation.

For now the work around I have been using is to let Visual Studio create virtual directory for my web application. It targets the correct ASP.Net version and modifies IIS meta data correctly.

Views: 2943

Tags: , ,

ASP.Net | IIS

Silverlight:Error 2104 - Could not download the silverlight application, check the web server settings

by Viper 28. December 2008 18:48

For the first time I was trying to debug my silverlight application projects on Windows vista. Every time I was trying to load test page of my web application, i kept getting Error 2104, telling me that download of silverlight application is failing. For a moment I thought it may be settings in my browser that are preventing download of this silverlight application. I could not find anything strict in my settings that will prevent the download. Then i stsrtaed digging around and found that silverlight application has new file extension type ".xap" and its a new mime type as well. So I added a new entry in MIME types in IIS and there you go. It worked like a charm. Just add the following entries and you will be all set.

File Extension: .xap

Mime Type: application/x-silverlight-app

Views: 4162

Tags:

ASP.Net | Visual Studio | VPN | IIS

Powered by BlogEngine.NET 1.5.1.7
Theme by Naveen Kohli