开发者

Reading the url from the browsers address bar using C# and MVC

I am trying to use domain masking to simulate multi-tenant access to my application. The plan right now is to read the subdomain portion of the dom开发者_运维知识库ain ie: demo.mydomain.com and load settings from the DB using that name.

The issue I'm having is that request.url is getting the request url - NOT the url in the browser.

So if I have http://demo.mydomain.com forwarding to http://www.mydomain.com/controllername with masking, request.url is grabbing the latter, simply because of how masking works, i assume - by putting the masked site inside of a frame.

Is it even possible to read the url in the browsers address bar? Thanks.


You probably can get the url you want, but at the client side...

So, do this:

  1. Get the browser's url by using a javascript call, like window.location.href.
  2. Post that url to the server-side.

Cons:

  1. This is a javascript dependent solution, it will not work with javascript disabled.
  2. This is ugly as hell.

Pros:

  1. You probably do not have any other option.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜