ASP.NET MVC website getting redirected to local IIS instead of IIS express on any browser

为君一笑 提交于 2019-12-01 05:59:46

问题


Aim:

Locally run ASP.NET MVC website on IIS express on any browser.

History:

The project in concern is an ASP.NET MVC website which initially was setup to use Local IIS with SSL enabled. I tried to set it up on IIS express:

RouteConfig.cs file

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

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

There are 2 redirection possibilities in web.config

For authentication

<authentication mode="Forms">
  <forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>

For error handling

<customErrors mode="RemoteOnly" defaultRedirect="~/Views/Error/Error.html" redirectMode="ResponseRewrite">

Problem:

Although the above setting is done, the site is getting redirected to Local IIS (https://localhost) instead of IIS express (e.g. http://localhost/12345 or https://localhost/12345).

What is tried so far:

  • Apply server settings to all users (store in project file) is checked.
  • Added _CSRUN_DISABLE_WORKAROUNDS and repaired IIS
  • MVC WebApplication no longer starts in IIS Express (redirects to https://localhost in Chrome)
  • Tried recreating virtual directory
  • UrlRewrite is not stopped
  • Old certs are deleted

There is a question mark on the site which inside IIS, this must be ignorable

After removing https binding, the redirection is happening however the page seems to be not loading.

Visual studio is allowing to debug the Application_Start() and Configuration(IAppBuilder app). Afterwards, any break point is not hit.

This is happening with all controllers and actions on all browsers.

Where am I going wrong? or is it some bug?


回答1:


Not sure what is the hack behind this...

To run an ASP.NET MVC website on IIS Express (instead of Local IIS) with SSL enabled, one need to make sure that the 5 digit URL port starts with 443xx

where xx can range from 0 to 99

Now, the redirection is also not happening. The website is perfectly running on IIS Express



来源:https://stackoverflow.com/questions/34130579/asp-net-mvc-website-getting-redirected-to-local-iis-instead-of-iis-express-on-an

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!