It might be a simple thing for you but I just started (1 week ago) to program with Sharp C# / Razor for my intranet web site. So I was able to learn a lot of things in the last week.
How to use CSS stylesheet
How to use C# Layout pages
So now that I can write a create web pages I’m looking for a way to organize the folders behind my website.
Fair and simple, many different department so I would like to have a the main pages on the root of my folder architecture but the pages for the departments in their own folders… So here is an example :
|- Default.cshtml
|- _siteLayout.cshmtl
|- _PageStart.cshtml
|- stylesheet.cshtml
|-------| Accounting
|-------|- acc_main.cshtml
So default.cshtml works great… cause all the files are in the root… but when I run acc_main.cshtml that is under Accounting folder… It gets the Layout properly that without any problem… Only problem… That’s the only thing it gets… No pictures shows… doesn’t get the CSS style either… so basically it gets the Layout and the acc_main.cshtml content… But no styles pictures or anything else that is in the root folder.
I hope I’m clear enough…
Sorry if it’s simple but I can’t find any information on the internet… all the Tutorials are about how to create a page with C# but
One thing to note with Razor (and Mvc) is that there are two structures:
Alas, when a view references a script, image or other assets, the browser will resolve them relative to the current url.
Example:
The url/route /accounting/default maps to acc_main.cshtml. If acc_main.cshtml has a link like
<img src="a.jpg"/>the browse will try to resolve it using /accounting/default/a.jpg.If you instead use
<img src="/images/a.jpg"/>things will work, assuming you put images in a folder named images.