Asp.net defalut style sheet edit/delete? - css

I am creating a new asp.net web application.
Application contains a default master page i.e site.master.
That Master page has link to site .css that was the by default css attached.
link href="~/Styles/Site.css" rel="stylesheet" type="text/css"
I removed site.css from my project(exclude from project) but its functionality survive. How this is happening? Why the styles gets not deleted or removed??
I am Using IE11.

Exclude from Project is not good way to do this.
Remove that file completely then you will not have that file loaded.
after that remove reference from master page or anywhere you are giving it.
Do CTRL + SHIFT+ F for entire solution search and search for that file name. so remove that references if you find.
now about browser cache issue. remove browser cookies and history. Or you have one more option like open your website and load with b y pressing
CTRL + F5. it will load your website totally fresh and with new code completely.

Related

Programmatically added stylesheet ASP.NET (VB)

I'm currently programmatically adding a stylesheet to my content page using VB:
Dim link As New HtmlLink()
link.Attributes.Add("rel", "stylesheet")
link.Attributes.Add("type", "text/css")
link.Href = "Styles/AddNewModelStyles.css"
Me.Page.Header.Controls.Add(link)
At first glance, this seems to be working as my web page is formatted properly. However, I added new styling to the stylesheet and nothing happened. I completely removed all styling from the stylesheet, refreshed the page, and nothing changed. It seems to me like the original stylesheet is being cached, but I can't figure out how to clear the cache. I've tried F5, Shift+F5, closing browser and opening new, all to no avail. Anyone have any ideas why this is happening?
Internet Explorer Go inside your browsers tools and select -> Internet Options -> General -> Browsing History -> Settings -> View Files
Select all of them and delete them and reopen your browser.
Google Chrome Ctrl+Shift+Del -> Select from the beginning of time in the drop down -> Clear Browsing Data
I was able to figure out the solution to my problem by using Inspect element to find where the stylesheets were being loaded in. When you programmatically add a stylesheet to a content page, the stylesheet link gets added to the master web page head tag, not the content page head tag. My stylesheet was ultimately in the wrong directory (the stylesheet directory of the content page, NOT of the master page), and moving it to the master page's directory solved the issue.

CSS in browser sources tab different to css in link

I have an application that loads some CSS from a url. The css is loaded from the HTML page using a link tag:
<link rel="stylesheet" type="text/css" data-ng-href="{{dynamicCss}}">
The dynamicCss variable is set in angular and it is a link of the type 'serverUrl/file.css?v=timeStamp'. The timestamp is generated by using timeStamp = new Date() * 1;
I am adding the timestamp to stop the css from being cached, as we allow css customisation and the css file needs to be recompiled by the server when the user customises the style.
There are other pages in the same application that load different css files, some of them without the timestamp, so they are cached. If I come from one of those pages, I can see the css that belongs to those pages in the source tab of my new page, even if those also have a timestamp to avoid caching.
My problem is: every time I deploy the code, if I look on the sources tab of Chrome and look for the css file, there is missing css when I compare it with the css file that the url 'serverUrl/file.css?v=timeStamp' loads. If I clear the cache the css in the sources tab of the browser matches the css in the link.
Any ideas of what is happening? Is there any problem with telling the browser to cache some css files and not others?
The problem was on the server side, some caching had been added.

Bootstrap not rendering on index page on particular url

I have created an MVC project in ASP.NET 4.5 and designed the index page of home controller using bootstrap. When I browse to the url
http://localhost:59772/,
it gets rendered perfectly. But when I go to
http://localhost:59772/Home/Index,
which is essentially the same page, bootstrap doesn't gets rendered and everything appears as plain text without any styling. I have properly set the default values in route config as
Controller = home, action = Index
. Any help is appreciated.
The links are searched for in the current directory you are browsing. If you are on
localhost:12345/
It will look for resources in the project folder and if you are browsing
localhost:12345/home/index
It will look for resources in home folder, even though both the url's render the same page. Thats why bootstrap etc doesn't gets loaded the second time.

ASP.NET MVC Page not render when specify action

I'm having the following problem in my application.
When access a view, specifying only the controller, the entire layout of the master page is rendered correctly:
Eg:
localhost:50904/Contact
But when I specify the action, the layout of the master page is not rendered:
Eg:
localhost:50904/Contact/Index
localhost:50904/Contact/Success
I checked the HTML generated in both cases, and the generated HTML is correct. What can I be doing wrong?
Possibly you have references to .css files and those references are relative. Change the references to the .css files to start with / to make them rooted to the root of the site.
Press F12 and look for any errors in the console or network tabs.
You my find that the css or js files are not loading, check the paths if you see any errors.

CSS for sharepoint site settings

I've got a master page that loads in a custom css file. This works fine for the published pages that the end user sees. however, the css also affects the site settings pages which look terrible. Is there a way to only provide a custom css file for the published pages?
Cheers #Neps. There was a different master page for system, but I found out I was using the alternate CSS which was applying the style sheet to both. so I removed that and put the link code directly into the master page.

Resources