0

I'm using T4MVC in my project . but after deploying to a virtual directory e.g "/app" when I run the site all addresses were wrong . for example instead of being content/site.css it's /app/content/site.css and the browser can't find it .

for example I write :

<link href="@Links.Content.bootstrap_min_css" rel="stylesheet" type="text/css" />

that renders to

<link href="/app/Content/bootstrap.min.css" rel="stylesheet" type="text/css" />

instead of

<link href="Content/bootstrap.min.css" rel="stylesheet" type="text/css" />

how should I fix this problem ?

mohsen dorparasti
  • 8,107
  • 7
  • 41
  • 61
  • Can you please post more details? Specifically: what code exactly are you writing? What is it rendering when you View Source? What were you expecting instead? – David Ebbo Dec 04 '12 at 21:55

2 Answers2

3

Normally, this is the correct behavior. If your app is running under the virtual directory /app, then static files should be able to be requested using /app/content/site.css. So your first focus should be on trying to understand why this is not working.

If you really want to change this logic, look at ProcessVirtualPath in T4MVC.tt.hooks.t4. You can change the way the path is handled, and easily make it relative if you like. Make sure to rerun the T4MVC custom tool after changing this file.

David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • Is it possible to get virtual path of file without changing the standard behaviour of generated links? It would be useful in passing links to particular content in Bundle configuration. – Mariusz Pawelski Sep 09 '14 at 13:11
0

It would be helpful if you showed the code you use to reference the .css in your views. I imagine it is something like:

<link rel="stylesheet" type="text/css" href="/content/site.css">

You can specify an Application Root relative url using the following method (in Razor):

<link rel="stylesheet" type="text/css" href="@Url.Content("~/content/site.css")">

Hope that helps.

Paul Taylor
  • 5,651
  • 5
  • 44
  • 68