得到这样http://google.com一个完整的URL作为动作输入 [英] Get a complete url like http://google.com as action input

查看:169
本文介绍了得到这样http://google.com一个完整的URL作为动作输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要得到的网址在我的行动回报网页的PageRank。我有一个这样的路线:

I want to get url in my action to return the page's PageRank. I have a route like this:

routes.MapRoute(
    name: "PRURL",
    url: "Utility/PR/{*url}",
    defaults: new { controller = "Utility", action = "PR", url = UrlParameter.Optional }
);

但每当我去的http://本地主机:1619 /工具/ PR / HTTP://google.com 我只是得到一个 System.Web.HttpException ,告诉我从客户端检测到有潜在危险的Request的值(:)。我想解决这个问题但我不知道怎么办!

but whenever I go to http://localhost:1619/Utility/PR/http://google.com I just get a System.Web.HttpException that tell me A potentially dangerous Request.Path value was detected from the client (:). I want to resolve this problem but I don't know how!

任何人可以帮助我吗?

更新

我试过 [ValidateInput(假)] ,但它不解决这个问题!
的动作是这样的:

I tried [ValidateInput(false)] but it doesn't resolved the problem! the action is this:

[ValidateInput(false)]
public string PR(string url)
{        
    return GooglePageRank.PRChecker.PR(url);
}


UPDATE2
通过添加

<system.web>
   <httpRuntime requestValidationMode="2.0" />
</system.web>

问题没有解决! (

the problem didn't resolved! :(

最后
错误解决,但该URL从 http://google.com 更改为 HTTP:/google.com 和我自找的<一个href=\"http://stackoverflow.com/questions/11853025/input-url-like-http-site-com-changes-to-http-site-com-in-action-input\">here我得到了答案。

finally the error resolved but the url changed from http://google.com to http:/google.com and I asked for it here and I got the answer.

推荐答案

尝试到 requestPathInvalidCharacters 属性添加到的httpRuntime

<httpRuntime requestValidationMode="2.0" 
    requestPathInvalidCharacters="&lt;,&gt;,*,%,&amp;,\,?" />

默认值为&放大器;放大器; LT;,&放大器; GT;,*,%,&安培,:,\\,?

这篇关于得到这样http://google.com一个完整的URL作为动作输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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