Relative url automatic rewrite in asp.net MVC 2?

This happens because your head tag has a runat="server attribute (a nasty heritage from WebForms). Remove it and no rewrites will happen. Also instead of: link href="test.

Css" type="text/css you should always use Url helpers when dealing with urls: link href="" type="text/css You should not leave automatic rewrites to happen, always use Url. Content for linking static resources.

This happens because your tag has a runat="server" attribute (a nasty heritage from WebForms). Remove it and no rewrites will happen. Also instead of: you should always use Url helpers when dealing with urls: " type="text/css" /> You should not leave automatic rewrites to happen, always use Url.

Content for linking static resources.

I see, but I want the rewrite to happen but not only for the tag, for all tags like , thanks for your reply anyway – Ahmed Galal Mar 26 at 13:42 @Ahmed Galal, that's why you should always use Url. Content as in my example in order to specify urls. That's the correct way to set urls in an ASP.NET MVC application.

And for dynamic urls linking to controller actions you should use the corresponding html helpers: Html. ActionLink, Html. BeginForm, ... – Darin Dimitrov Mar 26 at 13:43 @Darin Dimitrov, I know about Url.

Content but I cant use it coz I dnt know where my folder will be placed, its a kind of a folder you upload to the server and its up to server where it should be saved. I only want to use relative URLs like what happens in the tag. – Ahmed Galal Mar 26 at 13:48 @Ahmed Galal, I don't understand.

Is this folder part of the web application root or it could be anywhere on the server? If it can be anywhere don't expect client browsers to be able to access it.It needs to be inside your server root and if it is simply use Url. Content("~/uploads") in order to get the correct relative path to this folder no matter where and how the application is hosted.

– Darin Dimitrov Mar 26 at 13:49 @Darin Dimitrov, Yes its a part of the web application root, but your folder might be renamed when its uploaded to the server, so you cant know the exact path – Ahmed Galal Mar 26 at 13:51.

Perhaps you have already tried something like this renders html as.

Thats works, however I was looking for a way that makes automatic url rewrite happens as it happens in the tag, thanks for your help – Ahmed Galal Mar 28 at 14:49.

And about why I dnt want to use Url. The folder name. Thats why using Url.

Content is useless for me, coz I don't know where my folder will exist or even the folder name. I was looking for an automatic URL rewriting. I think i'll have to make my own and filter response before sending it to the client.

I welcome any other ideas.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions