且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ASP.NET Core 找不到这个 localhost 页面

更新时间:2023-02-14 16:41:58

当我意识到我不小心删除了 StartUp 类的 Configure 方法中的默认路由时,我解决了这个问题:

 app.UseMvc(routes =>{路线.MapRoute(名称:默认",模板:{controller=Home}/{action=Index}/{id?}");});

Does anyone encountered this kind of problem? I think it has something to do with the IIS or so... I am using IIS 10 also using VS2017 and ASP.NET Core. When I launch the application I saw this error:

This localhost page can’t be found

No webpage was found for the web address: http://localhost:44306/

I tried changing the port. But nothing works. I tried other application it works but only this project having this kind of error and I don't know why.

Any Idea how to fix this?

Update:

I solved this problem when I realized I had accidentially removed the default route in the StartUp class' Configure method:

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