-1

I have a domain where I put many applications. My domains is in smarter ASP. I create a folder for each application.

Then the URI path like it to the next

How to get the right and left part of URL. By example:

http://siteofsites/site/controller/action?parameters

Where:

  • "siteofsites" is a domain.
  • "site" is my web app.

I need put in a variable.

var leftpart=http://siteofsites/site/
var rigthpart=/controller/action?parameters.

Is there a way to get this?

kayess
  • 3,394
  • 9
  • 28
  • 44
Carlos Aguilar
  • 63
  • 1
  • 1
  • 5
  • 1
    Possible duplicate of [Get application path without using httpcontext. (asp.net)](https://stackoverflow.com/questions/2409540/get-application-path-without-using-httpcontext-asp-net) – CodeCaster Aug 16 '17 at 15:04
  • No it´'s not sim, i need generated the url, this ex. is for the current controller – Carlos Aguilar Aug 16 '17 at 16:10

1 Answers1

0

You can use Request.Url which is available in the View and Controller.

@Request.Url.AbsolutePath  
-> "controller/action?parameters"

@Request.Url.Scheme + "://" + @Request.Url.Host
-> "http://siteofsites/site"
Georg Patscheider
  • 8,808
  • 1
  • 21
  • 34
  • I solucionate about left part with this var base_url = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') + "/"; the rigth part using replace function – Carlos Aguilar Aug 16 '17 at 16:29