最近将项目从.net 2.0升级到4.0,发布后首页的URL地址后面总是多出这样一个尾巴”ReturnUrl=%2f“
比如我输入“http://www.test.com“,立马会变成”http://www.test.com/Default.aspx?ReturnUrl=%2f“;但是我输...
比如我输入“http://www.test.com“,立马会变成”http://www.test.com/Default.aspx?ReturnUrl=%2f“;但是我输入”http://www.test.com/Default.aspx“,则一切正常。
展开
2个回答
展开全部
网址出现?ReturnUrl=%2f“
原因是你的web.config配置为Froms身份验证模式;
建议你找web 。cofnig然后将设置:
<system.web>
<authentication mode="Forms">
<forms name="Wrox" loginUrl="Login.aspx" path="/" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
找到上述类似代码替换成;如下;【如有疑问可以Hi我;请勿追加提问】
<system.web>
<authentication mode="Windows" />
<authorization>
<deny users="*" />
</authorization>
</system.web>
原因是你的web.config配置为Froms身份验证模式;
建议你找web 。cofnig然后将设置:
<system.web>
<authentication mode="Forms">
<forms name="Wrox" loginUrl="Login.aspx" path="/" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
找到上述类似代码替换成;如下;【如有疑问可以Hi我;请勿追加提问】
<system.web>
<authentication mode="Windows" />
<authorization>
<deny users="*" />
</authorization>
</system.web>
展开全部
<authentication mode="Forms">全部删掉,用过滤器实现认证并在过滤器中跳转页,类似于这样:
namespace site.filter
{
public class authorization : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
HttpContext ct = C.C.hc();
bool rv =false,
login = ct.User.Identity.IsAuthenticated,
authority = true;
if (login && authority)
rv = true;
else
ct.Response.Redirect("~/login");
ct.Session.Add("rv", rv);
return rv;
}
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
{
base.HandleUnauthorizedRequest(filterContext);
}
protected override HttpValidationStatus OnCacheAuthorization(HttpContextBase httpContext)
{
return base.OnCacheAuthorization(httpContext);
}
namespace site.filter
{
public class authorization : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
HttpContext ct = C.C.hc();
bool rv =false,
login = ct.User.Identity.IsAuthenticated,
authority = true;
if (login && authority)
rv = true;
else
ct.Response.Redirect("~/login");
ct.Session.Add("rv", rv);
return rv;
}
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
{
base.HandleUnauthorizedRequest(filterContext);
}
protected override HttpValidationStatus OnCacheAuthorization(HttpContextBase httpContext)
{
return base.OnCacheAuthorization(httpContext);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询