允许星号网址 [英] Allowing asterisk in URL

查看:158
本文介绍了允许星号网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个麻烦让星号(*)在我的网站的网址。我运行ASP.NET MVC 2和.NET 4.0。

I'm having a trouble allowing asterisk (*) in the URL of my website. I am running ASP.NET MVC 2 and .NET 4.0.

下面是描述该问题的一个例子:

Here's an example that describes the problem:

http://mysite.com/profile/view/Nice *

用户名是尼斯*和ASP.NET说,有非法字符的网址:

The username is Nice* and ASP.NET says there are illegal characters in the URL:

Illegal characters in path.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentException: Illegal characters in path.

我已经尝试了所有我见过的Web.config方法从网上,如:

I have tried all the Web.config methods I've seen online such as:

<pages validateRequest="false">

<httpRuntime requestPathInvalidCharacters="" requestValidationMode="2.0" />

所以我的问题是:是否有可能让星号的网址是什么?如果没有,是否有在.NET中的一些编码方法,它可以连接code星号(*)?

So my question is: Is it possible to allow asterisk in URL? If not, is there some encoding method in .NET that can encode asterisk(*) ?

谢谢!

推荐答案

我的解决办法是将其更改为一个查询字符串。

My solution was to change it to a query string.

例如:

http://mysite.com/profile/?user=username *

这样,它似乎工作得很好。

That way it seems to work just fine.

我不知道,星号(*)是保留字符,因此我不应该甚至允许用户名拥有它。但是,这解决了我的问题。

I do know that asterisk (*) is a reserved character and thus I shouldn't even allow usernames to have it. But this solves my problem.

这篇关于允许星号网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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