Search code examples
c#asp.netmodel-view-controlleraspnetboilerplate

Incorrect Base URL for Application


I have an ASP.net MVC app, built using the ASPnet Module Zero framework. For some reason all of the page URLs seem to be prefixed with /Account/Login, even when I'm already logged in. For example, the login page's URL is:

localhost:62114/Account/Login/Account/Login

Once logged in, the one application page is

localhost:62114/Account/Login/App/ListAllAccount

Trying to access any page without the /Account/Login in the URL, automatically causes an Error 404. appsettings.json looks like this:

"App": {
    "WebSiteRootAddress": "http://localhost:62114/",
    "CorsOrigins": "http://localhost:62114"
},

The route configuration looks as follows:

    routes.MapRoute(
        name: "default",
        template: "{controller=Home}/{action=Index}/{id?}");

    routes.MapRoute(
        name: "defaultWithArea",
        template: "{area}/{controller=Home}/{action=Index}/{id?}");

All of the services and resources also use the correct URLs, which means that you actually cannot log in, as you cannot access the service URLs.

EDIT: One thing that I noticed now is that it is only when I debug the application locally. Once published, the issue seems to go away.


Solution

  • For those who stumble onto this post from Google, the issue seems to be the combination of Visual Studio, .net core and IIS Express. I went to go play around in the Project Properties and found an option named "Launch" in the "Debug" tab. Changed it from "IIS Express" to "Project" and it now runs just fine.

    Note: It seems to be normal for it to open up a console before opening the browser, and the port will differ, but I haven't found it making any difference.

    enter image description here