Disable auto Friendly URLs in a Web Form project

那年仲夏 提交于 2020-01-03 09:11:40

问题


I created a C# web form project in Visual Studio 2013. When I run my sample.aspx page, the page automatically uses the /sample friendly URL routing.

I want to handle the routing myself manually and not let .NET to do it automatically. How can I disable the friendly URL feature. I don't want it uninstalled via NuGet, but only disabled in code.


回答1:


You could also just set the AutoRedirect mode to Off. This kinda gives you the best of both worlds.

    public static class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        var settings = new FriendlyUrlSettings();
        settings.AutoRedirectMode = RedirectMode.Off;
        routes.EnableFriendlyUrls(settings);
    }
}



回答2:


In your solution, open RouteConfig.cs (in the App_Start directory) and comment out or remove this line

    routes.EnableFriendlyUrls();



回答3:


After uninstalling the NUGET package and deleting all the dll you must clear the browser cache



来源:https://stackoverflow.com/questions/25426839/disable-auto-friendly-urls-in-a-web-form-project

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