isAuthenticated 在重写的页面上无法识别
我在网站上使用 UrlRewriting 模块,但似乎无法让 HttpContext.Current.Request.IsAuthenticated 在任何重写的页面上返回“true”。
如果我转到我的主页(http://localhost/default.aspx),我会得到“true”,但如果我去类似 (http://localhost/contactus) 我总是得到“假”。
为什么会这样呢?
另外,举一个直接的例子,我有一个编辑栏,应该向任何经过身份验证的人显示。 if 语句在 Page_Load 方法中触发
If HttpContext.Current.Request.IsAuthenticated Then _
Me.FindControl("EditBar").Visible = True
我也尝试将其放入页面加载事件中
Response.Write(HttpContext.Current.Request.IsAuthenticated.ToString)
每个被重写的页面都显示“False”,而未重写的页面则显示“True”。
I'm using the UrlRewriting module on my site and I can't seem to get HttpContext.Current.Request.IsAuthenticated to return "true" on any rewritten pages.
If I go to my home page (http://localhost/default.aspx) I get "true", but if I go to something like (http://localhost/contactus) I am always getting "false".
why would this be?
also, for a direct example, I have an edit bar that is supposed to appear to anyone who is authenticated. The if statement fires in the Page_Load method
If HttpContext.Current.Request.IsAuthenticated Then _
Me.FindControl("EditBar").Visible = True
I have also tried putting this in the page load event
Response.Write(HttpContext.Current.Request.IsAuthenticated.ToString)
Every page that is rewritten says "False" where pages that are not rewritten say "True".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了类似问题。将以下内容添加到您的 web.config 是否可以解决您的问题?
I had a similar issue. Does adding the following to your web.config fix your problem?
嗯,只要我的问题中的代码不起作用,那么这段代码就起作用了。
Hmm, wherever the code in my question DIDN'T work, then this code did.