I want to create a web application using C#/MVC5 with the following folder structure, where my client sources are separated from the server's ones
- Controllers
- HomeController.cs
- FooApiController.cs
- Client
- assets ( folder )
- images ( folder )
- logo.png
- font.ttf
- images ( folder )
- components ( folder )
- foo ( folder )
- fooService.js
- foo ( folder )
- index.cshtml
- web.config (EDIT)
- assets ( folder )
I want to be able to call my differents files in the client folder, without the folder 'client',e.g:
<img src="assets/images/logo.png" />
instead of
<img src="client/assets/images/logo.png" />
Moreever, I want to route all the others files to client/index.cshtml. I though about adding a route like this :
routes.MapRoute(
name: "Default",
url: "{*anything}",
defaults: new { controller = "Home", action = "Index" }
);
HomeController.cs
public class HomeController : Controller
{
public ActionResult Index()
{
return View("~/client/index.cshtml");
}
}
And adding rules as specified in this post for each folder in my client folder. e.g :
<rule name="client" stopProcessing="true">
<match url="^assets/?(.*)$" />
<action type="Rewrite" url="/client/assets/{R:1}" />
</rule>
The problem with this is that whenever I tried to get my image
http://localhost:49312/client/assets/images/logo.png
or
// returns to http://localhost:49312/client/assets/images/logo.png
http://localhost:49312/assets/images/logo.png
I get a 'Ressource not found' error
What is the proper way to go ?