查询字符串以斜线和QUOT; /"在asp.net mvc的不工作? [英] Query string with slashes "/" not working in asp.net mvc?

查看:111
本文介绍了查询字符串以斜线和QUOT; /"在asp.net mvc的不工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在这里有一个特殊情况:

我的操作方法接受一个参数,这个参数有望成为一个完整的URL(如的 http://www.somesite.com/article/onesite?hello=whatever&etc=blah )。当老asp.net工作(哦,对不起你们,我的意思是网页形式),这工作得很好,但使用asp.net MVC和preparing所需的路径(/ myaction / {inputUrl没有约束时,在inputUrl)失败。如果URL有任何斜线我得到一个错误的请求异常。我该怎么办?我应该在URL匹配的Web URL传递添加一个正则表达式的约束?你怎么认为亲爱的SO格斯?


I have a special case here:
My action method accepts one parameter, this parameter is expected to be a full url (e.g. http://www.somesite.com/article/onesite?hello=whatever&etc=blah). When working with old asp.net (oh, excuse me guys, I mean web forms) this works just fine, but when using asp.net mvc and preparing the required route ("/myaction/{inputUrl" with no constraints on inputUrl) it fails. If the url has any slashes I get an "Bad Request" exception. What should I do? Should I add a regex constraint on the passed in url to match a web url? What do you think dear SO Gus?

PS:资源从一个iPhone应用程序,这意味着请求,我没有在未来URL任何控制(!也就是说我不能带code吧)

PS: The resource will be requested from an iPhone app, which means, I don't have any control over the coming url (i.e. I can't encode it!)

先谢谢了。

推荐答案

请参阅此问题<一href=\"http://stackoverflow.com/questions/591694/url-en$c$cd-slash-in-url\">http://stackoverflow.com/questions/591694/url-en$c$cd-slash-in-url.

即使UrlEn code将没有任何帮助。该行为MVC2改变。

Even UrlEncode will not help here. The behaviour changes in MVC2.

这篇关于查询字符串以斜线和QUOT; /&QUOT;在asp.net mvc的不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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