简体   繁体   English

MVC 4查询字符串值与句点

[英]MVC 4 querystring value with period

I am implementing OAuth2 into my MVC project. 我正在将OAuth2实施到我的MVC项目中。 At the moment I am working with Google Api. 目前,我正在使用Google Api。 The first step worked fine and my callback URL is being called with a parameter code which looks like this: 第一步运行良好,并使用如下所示的参数代码调用了我的回调URL:

code=4/O89-dMqK-MHn8ynzsEawrpYPL80Y.Mu61gsIzfDMYOl05ti8ZT3adNQ17fgI

the problem is that MVC is ignoring it because of the period (.) in the value. 问题是由于值中的句点(。),MVC忽略了它。 I need to know what I can do to get it to work. 我需要知道如何才能使其正常工作。 If I remove the period, then everything works as it should but I have no control over what google send back to me but I need to be able to read it. 如果我删除该期限,那么一切都会正常进行,但是我无法控制google发送给我的内容,但我需要能够阅读该期限。

I have tried adding a custom route looking like this: 我尝试添加一个自定义路由,如下所示:

public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.IgnoreRoute("{*robotstxt}", new { robotstxt = @"(.*/)?robots.txt(/.*)?" });

    // default MVC route
    routes.MapRoute(
        name: "Default",
        url: "{controller}/{action}/{id}",
        defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
    ).RouteHandler = new CmsRouteHandler();

    // OAuth route
    routes.MapRoute(
        name: "OAuth",
        url: "OAuth/OAuth2Callback*"
    );

    // CatchAll route
    routes.MapRoute(
        "Catchall", // Route name
        "{*url}"
    ).RouteHandler = new CmsRouteHandler();
}

but it doesn't appear to work :( 但它似乎不起作用:(

Cheers, /r3plica 干杯,/ r3plica

If you are using .NET 4.0, add this to system.web section of your web.config file 如果使用的是.NET 4.0,请将其添加到web.config文件的system.web部分

<httpRuntime relaxedUrlToFileSystemMapping="true" />

It should solve the problem 它应该解决问题

可能此设置可以解决此问题:
<system.webServer> <modules runAllManagedModulesForAllRequests="true"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM