In Self Hosting ASP.NET MVC application we have 2 options to manage resources :
- Files System
- Embedded Resources
Manage resources on File System just like IIS do it.
Get Css example. In order to bring JS or Image, just change contentType:
Controller:
- Files System
- Embedded Resources
Manage resources on File System just like IIS do it.
Get Css example. In order to bring JS or Image, just change contentType:
Controller:
public class ActiveDirectoryAuthenticationController : ResourcesController { public ActionResult Index() { return View(); } }
ResourcesController
public class ResourcesController: Controller { public HttpResponseBase GetResource(string resourceId) { Response.Clear(); Response.ContentType = "text/css"; Response.Write(Resources.ResourceManager.GetObject(resourceId)); Response.End(); return Response; } }CSHTML:<a href="@Url.Action("GetResource", "Resources", new { resourceId = some.css})"></a>Resource File:

No comments:
Post a Comment