0

I have several instalation with different path.

fe.:

  1. http://Somepath.xx/
  2. http://Someotherpath.xy/Maincontent/

Problem is, how to dynamycly detect the path?

I found way how to do this for first case:

Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host + (Request.Url.Port != 80 ? ":" + Request.Url.Port : "")

But how to do this for second, or general for more complex example... i don't know.

I need it in controller as same as in View

Zdenek G
  • 311
  • 1
  • 5
  • 16

2 Answers2

0

You could use the Url.Content method:

string root = Url.Content("~/");

The Url helper is available in both controllers and views.

Darin Dimitrov
  • 960,118
  • 257
  • 3,196
  • 2,876
0

You can look at Server.MapPath functionality and see examples and informal explanation of its workings here

Hope this helps.

Community
  • 1
  • 1
Display Name
  • 4,676
  • 1
  • 29
  • 43