惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
云风的 BLOG
云风的 BLOG
美团技术团队
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
爱范儿
爱范儿
Stack Overflow Blog
Stack Overflow Blog
WordPress大学
WordPress大学
GbyAI
GbyAI
雷峰网
雷峰网
P
Proofpoint News Feed
IT之家
IT之家
人人都是产品经理
人人都是产品经理
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
T
The Blog of Author Tim Ferriss
月光博客
月光博客
V
Visual Studio Blog
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
T
Troy Hunt's Blog
Project Zero
Project Zero
U
Unit 42
T
Tor Project blog
Scott Helme
Scott Helme
L
LINUX DO - 最新话题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
I
InfoQ
Cloudbric
Cloudbric
P
Proofpoint News Feed
The Cloudflare Blog
H
Heimdal Security Blog
Google DeepMind News
Google DeepMind News
The GitHub Blog
The GitHub Blog
Attack and Defense Labs
Attack and Defense Labs
有赞技术团队
有赞技术团队
T
Threat Research - Cisco Blogs
T
The Exploit Database - CXSecurity.com
J
Java Code Geeks
博客园 - 【当耐特】
Security Latest
Security Latest
The Register - Security
The Register - Security
F
Fortinet All Blogs
I
Intezer
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
NISL@THU
NISL@THU
T
Tenable Blog

博客园 - JasonBie

使用NPOI编辑Excel C# datagridview 快速导出数据到Excel Outlook2016 不能自动配置企业Exchange的解决办法 Linq实现left join左连接 电脑端微信语音像机器人解决办法 解决sql server collation conflict Asp.net APP 重置密码的方式 jQuery dataTables 列不对齐的原因 JavaScript 获得客户端IP Entity Framework Linq 动态组合where条件 查询SQLSERVER执行过的SQL记录 Asp.net Web API 返回Json对象的两种方式 Read Excel file from C# JavaScript测试工具比较: QUnit, Jasmine, and Mocha MVC删除数据的方法 Session State Cookie Transferring Information Between Pages View State
Asp.net Form验证后造成URL参数重复的问题
JasonBie · 2012-11-29 · via 博客园 - JasonBie

开发Asp.net网站, 开发网站使用Form验证, 需要在Web.config中加入如下节点

    

<authentication mode="Forms">
      <forms loginUrl="~/Public/Login" timeout="30" />
    </authentication>


打开带有参数的页面时,如果未登录或登录已超时,会自动跳转到Login页面, 但是当输入完用户名密码后, 如果使用 this.HttpContext.Request.UrlReferrer 获取之前的页面就会发现获取到的Url中包含重复的参数列表.
至于为什么会出现重复,可以参考:
 http://blogs.msdn.com/b/vijaysk/archive/2008/01/24/anatomy-of-forms-authentication-return-url.aspx 

可以这样获得没有重复的Url:

var urlPathAndQuery = this.HttpContext.Request.UrlReferrer.PathAndQuery;
var returnUrlIndex = urlPathAndQuery.IndexOf("ReturnUrl=");
if (returnUrlIndex > -1)
{
    var parameterIndex = urlPathAndQuery.IndexOf("&");
    string returnUrl = parameterIndex == -1 ? urlPathAndQuery.Substring(returnUrlIndex + 10) : urlPathAndQuery.Substring(returnUrlIndex + 10, parameterIndex - (returnUrlIndex + 10));
    returnUrl = Server.UrlDecode(returnUrl);
    bool isNotLogoutUrl = returnUrl.IndexOf("Logout") == -1;
    if (isNotLogoutUrl)
    {
        return returnUrl;
    }
}