Web app on server not reading style sheets - asp.net

I am not sure why when I place the web app on the MS server 2008 R2 that it is not reading the style sheets on any pages.
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<link href="/styles/StyleSheet1.css" type="text/css" rel="stylesheet" />
The masterpage has no styles on it or anything on it except the ToolkitScriptManager. I placed it there for future use if needed.
Viewing the source shows the style links there and if I take a link and past it in the url the style sheet appears, so yes, it's there on the server.
http://serverName/WebAppName/styles/StyleSheet1.css
This occurs in all browsers.
The styles are being read in Visual Studio 2010 when debugging.
I tried placing a tilde (~) in front of the reference
link href="~/styles.....
This had no effect.
I tried removing the first forward slash even though I knew this was wrong.
I have been through the server configurations but with no luck.
I there a configuration in the server I am missing? It's been about two years since I had to do any configurations but it is nice to have access to the servers once again.
Thanks for any responses...

After doing a bit of research I found the answer and wanted to post it for a reference to others.
Yes, the link to the css file was broken after testing with Firebug.
Why was it broken? It was from the server.
When creating a directory in IIS for a new site, there are some choices.
I made the choice to create a new virtual directory under the Default Web Site directory.
Old habits die hard from my .Net 1.0 days.
This means the page was looking for the css folder in the wrong place and the href needed to be changed to href="styles/... without the first forward slash.
But when there are a LOT of pages to make changes, this is not a good idea.
What I did and should have done in the first place was create a NEW web site under the Sites folder in IIS. This way it's not a new Virtual Directory and the relative paths throughout the site are now correct.
I hope this post helps someone else in the future.
Thanks for all the replies and suggestions!!!

Related

Visual Studio Website Debug Server

I'm working on a few pages on a university website. As such, there are a lot of scripts, stylesheets, images, etc. that I have to pull from places where other people are updating them. All these includes are incorporated into HTML snippets that I'm pulling into an MVC layout page. Problem is, all the paths within those look like this: src="/oit/includes/foo.css">. We use a couple different servers here and there, so I guess that's for portability across servers, subdomains, whatever. That code isn't mine. The point is, when I want to debug my site, it's not going to find localhost:1337/oit/includes... etc. Is there a way to make the debugger think my page is on the university web server, or am I going to have to publish this every time?
I'm using Visual Studio 2012.
You could directly reference the resource from the correct server instead of using relative urls:
<link rel="stylesheet" type="text/css" href="http://someserver/oit/includes/foo.css" />

ASP.NET MVC in Subfolder/Virtual Directory/Routing/Domain issue

I posted the following question yesterday but didn't get a helpful answer.
May i was not clear enough, i am very sorry.
After hours of searching here and googling with Bing i could not solve
the following
Problem. It does not should a "heavy" Problem.
here is my problem
I have a Domain like http://example.com that is pointed to a
virtual directory on my webspace like
http://myprovider.com/VirtualDirectoryName/.
The folder structure on my webspace is (off course) like this
root
bin
VirtualDirectoryName
bin
Content
Scripts
Views
Web.config
Global.asax
If i call now "http://www.domain.com" i get the Site without CSS and the
links
are "http://www.domain.com/VirtualDirectoryName/".
I used the default and almost empty default "Internet Application". So
the routing
is default and all links are created with #Html.ActionLink.
Please help me, i tried so many things but i cant get it working. In my
local environment i can affect that with IIS settings but (off course) i
do not have access on the IIS settings of my host.
btw, my hosting provider provider is discount ASP.NET.
Thank you all!
How are you referencing the css files in your html?
If your referencing the like:
<link href="../../Content/Style.css" rel="stylesheet" type=\"text/css\" />
It might not be looking in the correct directory. Try the referencing it as the following:
<link href="/Content/Style.css" rel="stylesheet" type=\"text/css\" />
That way you reference it from the root.
A good way to check is to use the "net" tab within firebug this will show if they are loading and if not what location it is trying to find them.
Link your css and javascript this way (using ResolveClientUrl):
<link href="<%=ResolveClientUrl("/Content/style.css")%>" rel="stylesheet" type="text/css" />
The problem was a simple routing error. My Application was only a simple folder in the iis and not a virtual directory / application. After setting the folder to an application the problem is gone.
I think you can solve it using web.config at the root as suggested here How to host ASP.NET MVC site in a subfolder

Changed a page from ASPX to HTM(L) but IIS points to ASPX regardless

We recently rewrote our company homepage and have come across a peculiar error. We have very few pages that need any code behind them, so we wrote the website in static HTML served out of IIS6. The few pages that need any code (Contact Us, with a contact form, for instance) are .ASPX pages.
The previous version of the website had more .ASPX pages, even if there was no code in the code-behind. One of those pages was "management.aspx", and in the new site this is, logically enough, "management.htm". We're smart enough to not just change the file extension -- we rewrote everything, it just has the name in common.
Here's the peculiar part: Even though every link in the entire website points to "management.htm", IIS6 continues to try and serve "manangement.aspx". I've reset IIS, stopped/started the Default Web Site under IIS6, deleted pages from "Temporary ASP.NET Files" and deleted out temporary GZIP files from the server as well. This isn't MVC or anything, so we have no explicit URL routing, and while I can see us having to implement static file handling in our web.config httpHandlers, I can't imaging that being a necessity.
What gives? Why is IIS6 still trying to serve the old "management.aspx" page when we're explicitly asking for "management.htm"? What can I do to fix it?
Your bindings have to be off somewhere... check top level for *, *.htm, managment.htm, etc. Then check virtual directories.
If you paste "http://yoursite/management.htm" in your browser and you get a YSOD, this is an IIS issue for sure.
Check if you still have the bin folder in the root of your site.
Do you get a 404 because it tries to load management.aspx and it's not there?
Check the Default Page on the Website/Virtual directory in Question, and if it exists remove the reference to manangement.aspx.

CSSFriendly issue just after publishing to web server

I created a website and used css friendly adapters for Menu, TreeView and GridView, all was correct, but after publishing it to my great web server, the menus and treeviews didn't load and there is just some bullets!
Here is my work: http://jds.cot.ir (dead link)
Left side I have a menu which did not load.
Did you copy over the App_Browsers folder? I'd check you copied all files over and, if you can, restart the application pool (touching web.config should achieve this).
I found the problem and the solution, I have an error loading one css file:
<link href="/WebResource.axd?d=FmPs0x8PbK0cHdhnI4N-J7cB33HdEr5UOoA_QzdIwqZdeINM8Kod5dxru5SzZMkL0&t=633820044382031250" type="text/css" rel="stylesheet" />
and the content of this css was an error titled:
Specified argument was out of the range of valid values. Parameter name: utcDate
I changed my pc date to one month ago and rebuilt my solution, and upload it again.
And every thing is correct. ;)
Try deleting precompiled.config from the root of the web app on the server. That did it for me. Haven't really looked into what the pros and cons are. Looks like the publisher's precompilation doesn't take into account the control adapters for some reason. I just ran into this in VS2010 beta 2.

CSS file not getting downloaded in Visual Studio 2008 SP?

This might sound a little wierd, but all of a sudden the CSS and Javascript files referenced in my master page are not being downloaded while the page is being rendered. I am working on a ASP.NET MVC project and things were all fine like half an hour ago!
Here is what I have in head section of the master page,
<link href="/Content/MyCSS.css" rel="stylesheet" type="text/css" />
<script src="/Scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
I can see the CSS class intellisense while designing pages. But in the page source I do not see these files being added. I can see the css being applied in the VS designer. I have tried restarting VS, restarting my machine too.
Anyone else faced this situation before. I might go crazy now.
Sounds odd. I would use Microsoft Fiddler to see if that gives you any clues. Also are you using IIS or the built in Web server?
If you are using some kind of source control, you might also want to review your recent changes.
Check that your paths are correct. You can create a web app in a virtual directory off the root, so you path would be "/myapp/default.aspx", in which case your paths for your css and js would be wrong.
Try to avoid putting absolute paths in file references.
You may want to try and remove the leading slash, for example.

Resources