禁用Web窗体项目中的自动友好的URL [英] Disable auto Friendly URLs in a Web Form project

查看:68
本文介绍了禁用Web窗体项目中的自动友好的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2013中创建了一个C#Web表单项目.当我运行sample.aspx页面时,该页面会自动使用/sample友好的URL路由.

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.

我想自己亲自处理路由,而不是让.NET自动进行.如何禁用友好的URL功能.我不希望通过NuGet将其卸载,而只能在代码中将其禁用.

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.

推荐答案

您也可以将自动重定向"模式设置为关闭".这样可以给您两全其美的感觉.

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);
    }
}

这篇关于禁用Web窗体项目中的自动友好的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆