ASP.NET MVC and IIS 5

前端 未结 5 1512
别那么骄傲
别那么骄傲 2020-11-29 06:47

What is the best way to get hosting of an ASP.NET MVC application to work on IIS 5 (6 or 7). When I tried to publish my ASP.NET MVC application, all I seemed to get is 404 e

相关标签:
5条回答
  • 2020-11-29 07:08

    Answer is here

    If *.mvc extension is not registered to the hosting , it will give 404 exception. The working way of hosting MVC apps in that case is to modify global.asax routing caluse in the following way.

    routes.Add(new Route("{controller}.mvc.aspx/{action}", new MvcRouteHandler()) { Defaults = new RouteValueDictionary (new{ controller = "YourController"} ) });

    In this way all your controller request will end up in *.mvc.aspx, which is recognized by your hosting. And as the MVC dlls are copied into your local bin , no special setttings need to be done for it.

    0 讨论(0)
  • 2020-11-29 07:10

    Run: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll -i

    This will reset IIS registry settings for aspnet user.

    Create the virtual directory: 1. Right click on the directory you want to convert

    • select Properties
      1. under Directory, select Create.
      2. under Configuration, select Add.
      3. for Executable insert:

    C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll

    for Extension insert: .*

    • uncheck “Check that file exists”

    • under Documents add entry point file, ie: Default.htm, index.htm, Global.asax

    • under Directory Settings

      1. select Edit...
      2. select Anonymous access
      3. uncheck Allow IIS to control password
      4. uncheck Basic authentication
      5. uncheck Integrated Windows authentication
      6. under ASP.NET, make sure version = v4.0.30319

    TAKE NOTE of User Name ie: IUSR_AVSJ82S

    Set sharing permission of physical directory:

    • In windows explorer, go to the physical directory that was converted to a virtual directory. Right click the directory name
    • select properties
    • under security tab, select Add
    • enter the IIS User name ie: IUSR_AVSJ82S click check name.
    • click OK
    • set permissions to Read and Write.
    0 讨论(0)
  • 2020-11-29 07:13

    FYI:On server 2003 (developing an app that had to connect to the RPS), it didnt' allow me to add the extension .*, I used the alternate solution modifying the route clause, and that worked.

    0 讨论(0)
  • 2020-11-29 07:18

    I think either way you'll have to do Solution 1.

    Consider the HTTP Request pipeline.

    1. A request comes into IIS.
    2. IIS checks port/host header to see if it has a web site set up to capture requests for that host header/port.
    3. IIS investigates the file extension of the request (.php, .asp, .aspx) and hands it off to an ISAPI that can handle that type of request.

    Only at this point does ASP.NET (or a PHP runtime) kick in. If IIS does't have that mapping then it'll never hand off the request to the ASP.NET runtime and the request will never reach your code. That's why you need that glob (*) mapping to the ASP.NET ISAPI.

    ASP.NET MVC framework urls often end with no file extension at all. If you want these requests to get handled by ASP.NET (or some other runtime) you have to map all requests regardless of the file extension to that ISAPI (ie. aspnet_isapi.dll).

    This is often also done for HttpHandlers that need to serve off media like .jpg, .gif. For the handler to be hit it needs to get mapped to your code even though .jpg isn't a "normal" ASP.NET file extension.

    HTH,
    Tyler

    0 讨论(0)
  • 2020-11-29 07:22

    Have you tried adding .aspx to the end of the controller name?

    It worked for Stack Overflow question Where can I get ASP.NET MVC hosting?.

    0 讨论(0)
提交回复
热议问题