0

I'm trying to move an ASP.NET project made in Visual Studio 2013 on Windows 7 to IIS 6.0 on Windows Server 2008, and am having problems with navigation between pages.

In Visual Studio, I navigate from the Login page where the application starts to the Home page with this command:

Response.Redirect("~/Home.aspx");

which in Visual Studio correctly loads the Home.aspx file. But when I run this in IIS, the command instead tries to look for a Home folder, not a Home.aspx file, and therefore returns a 404 error unless I make a Home directory, which does not load the Home.aspx file even if I copy it to the directory.

What are possible reasons for this difference, and how can I get the application to run the Home.aspx page in IIS?

Robert
  • 41
  • 2
  • 9
  • A bit of a guess but check your site in IIS isn't set to `Integrated Pipeline` mode. For IIS6 it would have been `Classic` mode instead. Try and test on a non-production server 1st. http://stackoverflow.com/questions/716049/what-is-the-difference-between-classic-and-integrated-pipeline-mode-in-iis7 – scgough Mar 23 '17 at 16:15

1 Answers1

0

It looks like a routing issue. Was your VS 2013 web project created as an ASP.NET MVC web site? If it was you might have added some WebForms aspx pages to it, but in order to have both MVC and WebForms pages you have to adjust the routing configuration in App_Start/RouterConfig.cs:

If you comment out this code in the method RegisterRoutes() in RouterConfig.cs, then you will be able to hit Home.aspx:

routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 
        );

If you want only Home.aspx to be allowed while keeping MVC routing for all other pages then you will have to change the defaults value in the routes.MapRoute method call.

routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "<Some Other Controller Name>", action = "Index", id = UrlParameter.Optional } 
        ); 

If you change the controller name for the default route from 'Home' to something else, Home.aspx should load properly.

John Verco
  • 1,357
  • 9
  • 6
  • I looked at the file you mentioned, but the code for RegisterRoutes() is different than what you said it was: 'var settings = new FriendlyUrlSettings(); settings.AutoRedirectMode = RedirectMode.Permanent; routes.EnableFriendlyUrls(settings);' – Robert Mar 23 '17 at 17:04