How to set up IIS6 to host ASP .NET 4 MVC4 application - asp.net

I'm having a hard time configuring my server to host MVC4 application. Here's my situation:
I have Windows 2003 server SP2
Until now, all my hosted applications are targeted to .NET Framework 3.5, thus using ASP .NET 2. I use single web site to host web application
Now, I want to host very first application targeted to ASP .NET 4
What I did is:
I've installed .NET Framework 4
I've added new new application pool
I've added new virtual directory to my web site (the same web site that hosts ASP .NET 2 web apps) and converted it to web application. Next, I've selected ASP .NET version 4 on ASP .NET tab
So, I thought that it would be enough. But when I access my application with root url, the first thing I get is 403. I've checked security options and they seem to be all right.
Next, I tried to access one of my controller actions, eg:
http://servername/home/index
and now I get 404 error. Ok, so I've enabled browsing of files and I tried to access web.config, for to check what happens, and I received error:
Could not load file or assembly 'System.Core, Version=2.0.5.0,
Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or
one of its dependencies. The given assembly name or codebase was
invalid. (Exception from HRESULT: 0x80131047)
I've also run regiis command:
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis.exe -s W3SVC/2049612577/root/cip-new/
but still in vain. Bottom line, it's something wrong, but I have not idea what is happening.
EDIT 1:
I've made some testing. What I did, is I'd created a basic MVC4 application from Basic template and simply published it to the server. And it worked. However when I published it to the server to the same directory, I got the error:
The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047).]

2 things I've had to do in the past to get v4 working on IIS6...
Make sure the site using .Net version 4.x runs in it's own app pool, separate to sites using .Net version 2.x
If you are using Razor I've noticed that IIS6 doesn't immediately know what to do. So you need to configure the Application Extensions Mappings. Add an extension mapping for .cshtml or .vbhtml depending on whether using C# or VB. I think that's why you're getting your 404 errors.
Restart IIS or recycle relevant app pools once above applied if you can to make sure changes are in effect.

Related

How to resolve %DNX_PATH% in development environment?

I have a partially developed ASP.NET 5 application. The application has the following three sub projects:
Web
Web.API
Auth.Server
The Web project relies on the Auth.Server for the OAuth implementation and redirects to that project on load. There's some configuration related to the httpPlatform handler in the Web project's web.config.
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" forwardWindowsAuthToken="false" startupTimeLimit="3600" />
This throws a Bad Gateway error related to the httpPlatformHandler when I run or view in browser the Web project from VS2015. However I've tried publishing the site locally and hosting in IIS with httpPlatformHandler (version 1.2) installed on IIS which actually works.
I could see that this creates an approot folder with a web.cmd file that has %DNX_PATH% variable defined and that the web.config in wwwroot refers this particular approot/web.cmd file for the processPath attribute.
Question: What location should I point the processPath in the development environment?
I'm new to ASP.NET 5 and only have some basic reading under my belt.

Umbraco 7 - moving site getting a Microsoft.IdentityModel Error when trying to login

I've developed a site using the Umbraco 7 CMS system, all works great and I've been able to copy and deploy this to numerous other machines and severs without any issues.
However now that we have tried deploying this to the live server, we are unable to login to the backend Umbraco section. The error is as follows:
Received an error from the server
Server call failed for getting current user
Could not load file or assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Access is denied.
Exception Details:
System.IO.FileLoadException: Could not load file or assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Access is denied.
The only different here is that the live server is administered by a Plesk control panel. So the actual site within IIS were created using this. However we have full Remote Desktop access and have set all the required "full control" permissions. And have checked that we have the correct .NET versions installed. But with no luck.
Has anyone experienced this or have a fix, I've searched Google and can't find anything that works.
Thanks
I haven't run into this myself, but it sounds like the server where you are trying to run your live site does not have the Windows Identity Foundation installed. I'd try installing that on your production server. Alternatively, you could find Microsoft.IdentityModel.dll reference in your solution right click it, open its properties and set Copy Local to true. That will cause the referenced dll to actually be dumped into the bin on compile. If you then deploy those dlls from the bin, your live site should be able to find them. You might have to go through that a couple of times until you find all of the Windows Identity Foundation dlls you need to get to.
It sounds like WIF has been integrated into the .NET 4.5 framework. It is depreciated and you shouldn't use it unless you are developing with .NET 3.5 or 4. I wouldn't expect you to be having this problem on .NET 4.5. What version of .NET framework are you using?
See What is Windows Identity Foundation for more info on WIF
Was any of that helpful?

IIS 7/ASP.NET 4/MVC 3 Preview 1: random "Could not load file or assembly" errors

I'm using the new Razor ViewEngine with ASP.NET 4/ASP.NET MVC 3.
In both Cassini on my local machine (Win7 x64/VS 2010), as well as IIS7 (Windows Web Server 2008), I'm randomly getting "Could not load file or assembly" errors.
With Cassini, rebuilding the solution generally fixes the problem.
In IIS7, recycling the application pool generally fixes the problem.
It is always the same assembly - a "Core" project of mine that is referenced by the ASP.NET MVC project. The solution hierarchy looks like this:
"Core" project (this is the one identified in the "Could not load file or assembly" error)
"Data" project (LINQ-to-SQL models)
Core
ASP.NET MVC Site
Core
Data
All these references are project references. The stack trace of the error starts in the "Data" project, which references the "Core" project. Any ideas?
Please refer the following blog posts;
http://www.tugberkugurlu.com/archive/deployment-of-asp-net-mvc-3-rc-2-application-on-a-shared-hosting-environment-without-begging-the-hosting-company
It might help...

Default.aspx with IIS 6.0 and .Net 4?

We have deployed a .net 4 asp.net site on IIS 6.0.
Default.aspx is configured as one of the default document.
When we access the site using the following url
http://testsite
We expect it to render
http://testsite/Default.aspx
But instead we get 404 Not found error. We did not had this issue when it was deployed on .Net 2.0. Only thing that has changed on the server is that we use .NET 4 instead of .NET 2.0.
UPDATE: I tried the following link but it did not work.
Getting an ASP.NET 4 application to work on IIS6
The framework version on the server is .NET 4 RC. Will it help if we install the latest .NET 4 version on the server?
Update: The issue is resolved now. The problem was a Third party upload control that we were using which added its own HttpHandler in Web.Config. This HttpHandler started failing in the .NET 4.
With the new .NET 4 framework, comes some problems if you are running it on IIS 6 Windows Server. IIS 6 does not let you have more than one framework at the time running in the same instance like IIS7 that can create Application Pool targeting different framework.
When IIS 6 runs under ASP.NET 2.0 (3.0 and 3.5 are superset, not frameworks) you are going to hit this error if the application is 4.0
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.
Source Error:
Line 11: </configSections>
Line 12: <system.web>
Line 13: <compilation debug="true" targetFramework="4.0">
Line 14: </compilation>
Line 15: <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/> </ system.web>
You have a few options;
Downgrade the .NET application to 3.5 that Visual Studio 2010 makes it really easy. Just go to the Website properties -> Application tab and there is a drop down with all the framework releases, select 3.5, you VS2010 will reload the project and modify the web.config, if you added web service reference, that you may have to delete them and re-add them under 3.5
To configure the IIS6 and web config to solve the issue.
I deal with the second part:
In IIS 6 console, you need to right click you project and click the property and check the ASP.Net tab whether Framework 4 is selected or not. If not select the framework 4.
But still you might face the same error because of the application pool; you might have same application pool for two different framework web application.
IIS 6 does not let you have more than one framework at the time running in the same instance (means single application pool can’t use for two different frameworks) like IIS7 that can create Application Pool targeting different framework.
To solve this issue you need to create application pool and assigned this application pool to you framework 4 web application.
To assign the application pool, in IIS console open the properties section of the web application, and click on the “Home directory” tab and selection application pool which you have created earlier from drop-down-list.
This two might now solve your problem completely sometime. You can get the error as
“404 Page is not found”.
Though you might now have any issue while in development time.
Basically page is not found issue is cause of other problem which is set hidden by is IIS6 . But you need to see the real cause. What you have do here is go to the IIS6 console open “web service extension node” which is right below the “default website” node. You will see the entire ASP.Net framework list over there, by default these frameworks might be prohibited so please select ASP.Net Framework 4 and click allow button.
Browse you website now, you get other error beside “404 Page is not found”. You might get the error as listed below:
The value for the 'compilerVersion' attribute in the provider options must be 'v4.0'
You’ll see following error when browsing the website
The value for the 'compilerVersion' attribute in the provider options must be 'v4.0' or later if you are compiling for version 4.0 or later of the .NET Framework. To compile this Web application for version 3.5 or earlier of the .NET Framework, remove the 'targetFramework' attribute from the element of the Web.config file.
To solve this issue, you need to modify your web config file as below:
Previously the CompilerVersion value is set as v3.5 but we already change our targetFranework to 4. Thus according to the error message above the 'compilerVersion' attribute in the provider options must be 'v4.0' or later if you are compiling for version 4.0 or later of the .NET Framework.
Hence your new setting will be as below:
<providerOption name="CompilerVersion" value="v3.5"/>
Hope this will solve your ASP.Net 4 migration and hosting issue at IIS6.
Here is a link to a more complete solution and explanation of this:
http://johan.driessen.se/archive/2010/04/13/getting-an-asp.net-4-application-to-work-on-iis6.aspx
Check the server logs, they will probably give you a better idea of what is going on.
You can find the path to the log file by right clicking the website in IIS and go to properties. Then goto the Web Site tab, under 'Enable logging' click properties and the logging properties window will show up which displays the path to the log file.
I think in 4.0 the default page setting is actually stored in the web.config. With the IIS 7.0 , IIS reads the web.config the determine what to do for the default page. I think IIS 6.0 is not reading the setting.

Issues within an ASP.NET 2.0 Web Application to Look for When Running on Linux with Mono

My IT department and I are trying to get an ASP.NET web application to run on a Linux with Mono. We have been working on this for about a month to no avail. The Mono setup on the Linux server seems to be good. We are able to run the demo ASP.NET pages on the server and they work fine.
I developed my ASP.NET web application with Visual Studio 2008, and I recently downgraded the application to ASP.NET 2.0. Originally it was in ASP.NET 3.5, which might be the problem. After publishing the web app, I received the following files: Default.aspx, Web.config, bin (with a .dll and a .pdb file), and an empty App_Data file. So far, the error that keeps occuring is an appication error on the server.
For a simple test, I made a simple ASP.NET web app that had a label and a button. We tried that app and it did not work either. Does anyone know of things that I should look for within my ASP.NET web application that would inhibit the application to work?
Application error:
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a "web.config" configuration file located in the root directory of the current web application. this tag should then have its "mode" attribute set to "Off".
!--web.COnfig Configuration File--
configuration
system.web
customErros mode+"Off"/
/system.web
/configuration
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's configuration tag to point to a custom error page URL.
!--Web.Config Configuration File--
configuration
system.web
customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/
/system.web
/configuration
Thank you,
DFM
Just for a resolution, I finally figured out what the problem was. The ASP.NET web app has an onload event that enables the web app to read an Access Db. For testing purposes, I did not update the ADO.NET Db path for the web app to read the Db so every time it was loaded through Mono, the generalized error in question would occur. After deleting the onload event, the web app functioned perfectly. Additionally, I had to downgrade the web app to ASP.NET 2.0, instead of 3.5, and delete the LINQ namespaces, which were not being used.
All I have to do is change the path(s) to point to the App_Data folder and place the Db in the folder, as well.

Resources