简体   繁体   中英

How to deploy ASP.NET MVC application in a shared hosting without losing the beautiful uri?

I am trying to upload an ASP.NET MVC application in a shared server running on IIS 6 and Windows 2003. I don't have access to IIS. I've changed the global.asax.cs file as follows:

        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default",
            "{controller}.aspx/{action}/{id}",
            new { action = "Index", id = "" }
          );

        routes.MapRoute(
          "Root",
          "",
          new { controller = "Home", action = "Index", id = "" }
        );

It is working fine, but it doesn't drop the .aspx at the end of the controller. Is there a way to remove the .aspx extension in the URL?

No, it's because your host has not set IIS to send all requests through ASP.NET. The only thing you can do is to ask your host to change this setting.

As far as I know you're URI's should work off the bat providing you are on IIS7.

If you are on IIS6 however you will need to jump through some hoops to get extensionless URI's.

This guide may help - haacked.

As far as I can tell though you'll need access to handler mappings in IIS6, which you probably won't have on your shared host.

Change the host. Seriously. Shared hosting STILL using IIS 6 - that is brutal. Hosts should have switched over quite some time ago.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM