English 中文(简体)
访问请求。 Url, when use ajax in MVC
原标题:Visit Request.Url when use ajax in MVC

当我访问<代码>查询时。 Url, 当使用千兆克时,陶尔会添加一些标签,如:

www.test.com/home/index/4?X-Requested-With=XMLHttpRequest

如何获得实际ur,或如何在没有硬ding的情况下拆除tag子?

问题回答

您可以使用:

string url = Request.Url.AbsolutePath; // should give you /home/index/4

并且如果你想要绝对ur,你可以尝试:

var builder = new UriBuilder(Request.Url);
builder.Query = string.Empty;
string url = builder.ToString(); // should give you http://www.test.com/home/index/4




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签