Archive for the ‘IIS7’ Category
ASP.MVC 2 – How to migrate project from ASP.NET 2.0 .NET Framework 3.5 to ASP.NET 4.0 .NET Framework 4
So you have decided to move your ASP.NET MVC2 project from the Windows Server configured with ASP.NET 2.0 .NET Framework 3.5
to ASP.NET 4.0 .NET Framework 4.
Here is how I did it.
My old setup:
Windows Server 2008 R2
IIS 7.5
ASP.NET
Application Pool : .NET Framework v2.0.50727
.NET Framework installed: 3.5 SP1
My new setup:
Windows Server 2008 R2
IIS 7.5
ASP.NET
Application Pool : .NET Framework v4.0.30319
.NET Framework installed: 4.0
The good thing is that the ASP.NET is backward compatible. You shoud publish the website on the new setup and it should work straight away.
In my case I had to remove these from web.config:
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirepermission="false" allowdefinition="MachineToApplication"></section> <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirepermission="false" allowdefinition="Everywhere"></section><section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirepermission="false" allowdefinition="MachineToApplication"></section><section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirepermission="false" allowdefinition="MachineToApplication"></section><section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirepermission="false" allowdefinition="MachineToApplication"></section>
If it still gives you problems got to IIS Manager and click Error Pages:

Select 500 , right click and select Edit Feature Settings
Here select “Detailed errors”

Now you should get detailed error within your web.config. Also check Event Viewer under the section Administrative Events
How to remove Server, X-AspNet-Version, X-AspNetMvc-Version and X-Powered-By from the response header in IIS7
You can check your response headers by using Firebug add-on for Firefox or just hit Ctrl+J in Chrome.

Unwanted info:
Server Microsoft-IIS/7.5
X-AspNetMvc-Version 3.0
X-AspNet-Version 4.0.303319
X-Powered-By ASP.NET
1. Removing X-AspNet-Version
In web.config stick this line in
<system.web>
<httpRuntime enableVersionHeader="false"/>
...
2. Removing X-AspNetMvc-Version
In Global.asax.cs add this line:
protected void Application_Start()
{
MvcHandler.DisableMvcResponseHeader = true;
}
3. Removing or changing Server
Add this module class to your project.
using System;
using System.Web;
namespace Project.Infrastructure.Web.Modules.Http
{
public class CustomHeaderModule : IHttpModule
{
public void Init(HttpApplication context)
{
context.PreSendRequestHeaders += OnPreSendRequestHeaders;
}
public void Dispose() { }
void OnPreSendRequestHeaders(object sender, EventArgs e)
{
//HttpContext.Current.Response.Headers.Remove("Server");
// Or you can set something funny
HttpContext.Current.Response.Headers.Set("Server", "CERN httpd");
}
}
}
And add set it in web config
<system.webServer>
<modules>
<add name="CustomHeaderModule" type="StrongNamespace.HttpModules.CustomHeaderModule" />
4. Removing or changing X-Powered-By
Go to IIS7 Management Console and open HTTP Response Headers

And that should be it!
InstallSqlState.sql errors: ASPState_Job_DeleteExpiredSessions does not exist and The specified @name (‘[Uncategorized (Local)]‘) already exists
So........... you are configuring ASP.NET SQL session state and Microsoft's documentation tells you to execute InstallSqlState.sql found in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ but you always get this: If the job does not exist, an error from msdb.dbo.sp_delete_job is expected. Msg 14262, Level 16, State 1, Procedure sp_verify_job_identifiers, Line 67 The specified @job_name ('ASPState_Job_DeleteExpiredSessions') does not exist. If the category already exists, an error from msdb.dbo.sp_add_category is expected. Msg 14261, Level 16, State 1, Procedure sp_add_category, Line 32 The specified @name ('[Uncategorized (Local)]') already exists. Well then..... you are doing it wrong. Open command line (Start->Run-> cmd) 1.cd C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ 2) Execute: aspnet_regsql.exe –ssadd -U <username> -P <passowrd> -S <servername> For example aspnet_regsql.exe –ssadd -U webuser -P d4rk!s1de -S mssql.arturito.net You can also do aspnet_regsql.exe –ssadd -E -S mssql.arturito.net - if you use Windows authentication
b) aspnet_regsql.exe –ssadd -U <username> -P <passowrd> -S <servername>for exampleb) aspnet_regsql.exe –ssadd -U webuser -P d4rk!s1de -S mssql.arturito.net
