我有一个项目,要求我的URL在路径中有点.例如,我可能有一个URL,例如www.example.com/people/michael.phelps
带点的网址生成404.我的路由很好.如果我通过michaelphelps,没有圆点,那么一切正常.如果我添加点我得到404错误.示例站点在带有IIS8 Express的Windows 7上运行.URLScan未运行.
我尝试将以下内容添加到我的web.config中:
<security>
<requestFiltering allowDoubleEscaping="true"/>
</security>
Run Code Online (Sandbox Code Playgroud)
不幸的是,没有什么区别.我刚收到404.0 Not Found错误.
这是一个MVC4项目,但我不认为这是相关的.我的路由工作正常,我期望的参数在那里,直到它们包含一个点.
我需要配置什么才能在网址中加点?
我尝试使用此代码检查用户是否在Application_BeginRequest和Application_AuthenticateRequest中扮演角色,但它不起作用.在BeginRequest中,代码永远不会被命中,并且使用某些请求对其进行身份验证,并且探查器不会显示.
只检查Request.IsLocal工作正常.
if(Request.IsAuthenticated)
{
if(User.IsInRole("Admin");
MiniProfiler.Start();
}
Run Code Online (Sandbox Code Playgroud)
任何想法或为什么它没有工作或更好的方式来做到这一点?
[更新]我接受了芒果,但解除了它,因为我没有完全做到这一点
我做了以下但是探查器最初没有出现.经过几次尝试后,它开始出现,即使我试图以隐身模式访问网站,所以没有cookie.
protected void Application_PostAuthorizeRequest(Object sender, EventArgs e)
{
if (User.IsInRole("Admin"))
{
HttpCookie cookie = HttpContext.Current.Request.Cookies.Get("RoleProfiler");
if (cookie == null)
{
cookie = new HttpCookie("RoleProfiler");
cookie.Value = "yes";
cookie.Expires = DateTime.Now.AddDays(1d);
Response.Cookies.Add(cookie);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我正在检查
protected void Application_BeginRequest(Object sender, EventArgs e)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies.Get("RoleProfiler");
if ((cookie != null) && (cookie.Value == "yes") )
{
MvcMiniProfiler.MiniProfiler.Start();
}
}
Run Code Online (Sandbox Code Playgroud)
并在请求结束时结束.
protected void Application_EndRequest()
{
MvcMiniProfiler.MiniProfiler.Stop();
}
Run Code Online (Sandbox Code Playgroud)
[Update2]结束问题,忽略这一点,我被outputcache所拥有.