C# 如何在后面的代码中获取当前网址?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9911591/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 11:11:40  来源:igfitidea点击:

how to get current url in code behind?

c#asp.net

提问by user1298676

Possible Duplicate:
Get URL of ASP.Net Page in code-behind

可能的重复:
在代码隐藏中获取 ASP.Net 页面的 URL

I'm trying to hold current url in string in the code behind.

我试图在后面的代码中以字符串形式保存当前 url。

as example this is the current url address:http:www.stackoverflow.com/questions/ask/submit how I can hold this in string variable?

例如,这是当前的 url 地址:http:www.stackoverflow.com/questions/ask/submit 我如何将其保存在字符串变量中?

please help me out.

请帮帮我。

采纳答案by Curt

This will get you the full URL:

这将为您提供完整的 URL:

Request.Url.AbsoluteUri