Monday, 15 June 2015

ASP.Net MVC Empty - CSS won't be applied -


Currently I'm trying to learn some HTML and ASP.NET and I'm already confused.

I have created a new blank project with MVC settings and I can not style to work with CSS files.

My index-file uses a layout-page which uses itself (CSS) -file. I am using the following "syntax":

  & lt; Link href =@Url.Content ("~ / visible / normal / style.css") rel = "stylesheet" />  

At this point, I do not know that you need farer information (I do not really know what information you may need) - please tell me.

Presenting styles in MVC, using bundle config is best.

In your solution, you should have a folder startup

if you open the BundleConfig.cs file, And see the style bundle.

Something like this:

  bundles. Add (New Style Bundle ("~ / Content / CSS"). ("~ / Content / STYLE.css"););  

Above is the name of your bundle: "~ / content / css" .

To insert style sheets from this bundle, in the header / footer or anywhere in your scene.

  & lt; Head & gt; @ Styles.render ("~ / content / css") & lt; / Head & gt;  

If you do not want to use the bundle, you can Url.Content

  & lt; Head & gt; & Lt; Link href = "@ Url.Content (" ~ / content / STYLE.css ")" rel = "stylesheet" /> & Lt; / Head & gt;  

Or you can use simple HTML:

  & lt; Head & gt; & Lt; Link href = "~ / content / STYLE.css" rel = "stylesheet" /> & Lt; / Head & gt;  

Edit:

If you do not have an App_Start folder, then you can use it:

  1. Create an application_start folder

  2. Make this a new class name: bundle config.css

      public class bundle config {public Status blank registerbundles bundle compilation bundles) {bundle. Add (New Style Bundle ("~ / Content / CSS"). ("~ / Content / site.css"););  

    }}

  3. Add this line to the end of the Application_Start method in your Global.asax.cs file

    << / P>


No comments:

Post a Comment