我在代码隐藏中遇到此错误时收到此错误:if(Page.User.Identity.IsAuthenticated)
System.NullReferenceException: Object reference not set to an instance of an object.
当我使用context.RewritePath方法时显示此错误 http://localhost/page.apsx?id=22 - > http://localhost/hello-world/
Page.User.Identity.IsAuthenticated返回True,当我去page.aspx?id = 22但我得到
System.NullReferenceException: Object reference not set to an instance of an object.
当我去/ hello-world / url时出现错误。
答案 0 :(得分:0)
如果url.Contains(“List”)然后重写这样的url:
context.RewritePath(Utility.WebRoot + "List/Add.aspx", false);
我的重写者并没有那么复杂。