Developing locally in Visual Studio 2010 my page looks great. When I deploy to the development server there is extra spacing and font size differences that mess things up.
Maybe it is because locally the Visual Studio rendering engine is iis7 vs on the development sever it is iis6.
How do I resolve this?
Thanks!!
Mark
You mean pages look different when viewed from the same browser? The only thing I can imagine is that you're missing some files (like CSS) when deploying.
That's probably got something to do with the IE Compatibility settings.
When you browse an intranet site; IE, by default, displays it in Compatibility View. So you may want to browse your application from different locations (local, internet, intranet) and check IE -> Tools -> Compatibility View Settings for the option "Display Intranet sites in Compatibility View". Turn it off and refresh to see if it works.
IIS got nothing to do with the page look and visual design.
You're probably viewing the page via the internal Visual Studio browser - don't do that.
Instead, right click the page and choose "View in browser" to open it with "real" browser like IE, FF or Chrome.
Try placing the link tag that references your css file out of your master page's contentPlaceHolder with id head as shown below,
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Title1</title>
<link href="~/css/layout.css" type="text/css" rel="stylesheet" media="all" runat="server" />
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
</body>
</html>
This fixed my issues while running through iis..
Related
Question: Why am I not getting .css intellisense while coding the HTML in Durandal ~/App/Views/###.html pages.
Steps to Recreate:
In Visual Studio Professional 2012 I've began an "empty" ASP.NET Web Application and added Microsoft ASP.NET Web Optimization Framework 1.0.0 Nuget Package to my solution. I've also included Durandal 1.2.0 and Bootstrap 2.3.1.
After adding the above mentioned references to my application I've added a shell.html page to the ~/App/ folder that was generated when Nuget installed the Durandal package.
As a sidenote, the .css files are working fine once I debug the application. I have multiple .css files including the Bootstrap.css file (installed with Bootstrap 2.3.1 (mentioned above)) in my ~/Content/ folder and the ~/App_Start/BundleConfig.cs which are referencing and using the .css files as they should during runtime.
Lastly, when I go through the PluralSight Single Page Apps JumpStart tutorial and get to the Coding the Shell with Durandal.js section we see clearly that I'm/we're supposed to get intellisense, but I do not.
Thank you.
UPDATE:
I was just made aware "the issue has been routed to the Visual Studio Product Team for triage and resolution."
The CSS should work in VS 2012. I always install Web Essentials too, as it helps tremendously (its like an incubator for VS features between releases)
For the JavaScript intellisense ... when using require.js it is harder to get that. THe best way I found is to use Resharper's plugin for VS. It gives me intellisense on JavaScript, even when using require.js.
I solved the problem by adding an explicit bootstrap.css reference in the Site.Master (I am using master pages in my app)
<head runat="server">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><%: Page.Title %> - My ASP.NET Application</title>
<asp:PlaceHolder runat="server">
<%: Scripts.Render("~/bundles/modernizr") %>
</asp:PlaceHolder>
<webopt:bundlereference runat="server" path="~/Content/css" />
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<link href="Content/bootstrap.css" rel="stylesheet" />
</head>
We have an old project lying around with these <meta> tags in every page. This website is an intranet web application.
<meta name="GENERATOR" content="Microsoft Visual Studio 7.0" />
<meta name="CODE_LANGUAGE" content="C#" />
<meta name="vs_defaultClientScript" content="JavaScript" />
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5" />
Do they have any value or use?
Is it safe to remove them?
I'm using VS2005 if that matters for the intellisense.
They have no use for web clients (other then leaking information about your development environment and using up bandwidth) only for your development environment.
I believe that the vs_defaultClientScript and vs_targetSchema are used for intelisense. You can remove the other tags without any problems.
On some machines it can cause slow loading of the page in IE 11, but it's not clear, on what it depends. Just one user in the office had problems - had to wait 5 - 10 seconds for loading the page, which other users saw immediately... on same Win 7 and IE 11. I removed
and it's OK.
When start debug mode of my asp.net website, it renders in my browser with the url
http://localhost:111/mywebsite/Default.aspx
The css file is referenced like this in the html
<link href="~/css/style.css" runat="server" rel="stylesheet" type="text/css" />
So naturally the site breaks because it looks for the CSS file in localhost:111/css/ instead of localhost:111/mywebsite/css/.
When I launch the website, it will actually be served from the url:
http://mywebsite.com
So is there a way to reference my stylesheet properly in both my dev and production area with a simple prefix like <?=$site_url ?> or something?
Additional info
In my solution explorer, I see that my project is marked with the path C:\...\mywebsite. Is that why the ~ assumes my project is always in a subdirectory? How do I tell Visual Studios that this project should always be served as something like http://localhost:111/Default.aspx?
This is what I see in the page source of both my localhost and production server:
<link href="~/css/style.css" rel="stylesheet" type="text/css"></link>. The css is active on production, but not my localhost.
I went to the solution explorer, then selected the item in the tree labelled C:\...\mywebsite, then I went to the Properties window at bottom right of VS, and changed the Virtual path to /. Now my dev website's root is the same as my prod website's root.
This will do the trick.
<link href="<%=ResolveUrl("~/css/style.css")%>" runat="server" rel="stylesheet" type="text/css" />
You already have, ~ resolves to the root of the website when the page is rendered.
Further reading: http://weblogs.asp.net/fmarguerie/archive/2004/05/05/avoiding-problems-with-relative-and-absolute-urls-in-asp-net.aspx (which works in chrome, FF and IE).
~ resolves on the server (which is why you need runat="server").
This code is run to generate the response from a HTTP request that has come to your dev server which is hosting the site from the location of the project on your disk.
~ doesn't assume that the site is in a subdirectory, the dev server will know the root of the website.
In production the site is being hosted by IIS from another location on the disk of the server machine.
Change it to:
<link href="/css/style.css"" rel="stylesheet" type="text/css" />
Remove runat="server" (if you don't need it).
Instead of href="~/css/style.css" use: href="/css/style.css"
href="/css/style.css" means that there is a folder named css in root of your website and a file named style.css inside it.
UPDATE:
As pointed out by comments, this solution only works if your app is running in root.
I have an ASP.NET (framework 2.0) web app running under IIS7.
When I run the app on the server, using IE8, localhost the app runs the way it is supposed to.
When I run the app in Visual Studio 2008 (framework 2.0) it runs the way it is supposed to.
But when I try to run the app from another computer it renders incorrectly.
Same versions of IE8.
What would cause the serving of an ASP.NET application to render correctly on the server, but incorrectly when serving to another computer, when the Internet Explorer versions are the same?
Can anyone help?
You can force IE to work in a specific compatability mode with one of the following meta tags in the head:
<meta http-equiv="X-UA-Compatible" content="IE=4"> <!-- IE5 mode -->
<meta http-equiv="X-UA-Compatible" content="IE=7.5" > <!-- IE7 mode -->
<meta http-equiv="X-UA-Compatible" content="IE=100" > <!-- IE8 mode -->
<meta http-equiv="X-UA-Compatible" content="IE=a" > <!-- IE5 mode -->
Here is a link to more information regarding the compatibility meta tag:
http://msdn.microsoft.com/en-us/library/cc288325(VS.85).aspx
One other thing you could try is to save the output source on each system and then compare to see if they are the same. If they are identical then it comes down to the rending on the client which is a compatibility setting.
I have a Visual Studio 2008 .NET 3.5 Web forms project that constantly shows warnings for my class tags in the html. I have the CSS file included in the master page with the following link:
<link href="/Css/Site.css" rel="stylesheet" type="text/css" />
The warnings I get are:
The class or CssClass value is not defined.
At run time all is good and everything works as expected but these warnings in VS are getting very annoying. Is there some other way to have this linked in? I don't get any VS intellisense on the html class attributes and when I click the warning and then hover over the class="something" attribute on the html the warnings all disappear. Next time I build all the warnings come back.
Any ideas?
EDIT: The file is in include in the project. I have also tried changing the link to:
<link href="Css/Site.css" rel="stylesheet" type="text/css" />
This gives me intellisense it seems but I still have the warnings...
I have also tried:
<link href="~/Css/Site.css" rel="stylesheet" type="text/css" />
This is seeming to work...
Why would they all work at runtime but each one cause different behavior in VS?
EDIT: So closed and re-open VS, the ~ is still being used but warnings are all back and not going away. So is there anything else I can try? The master page is in the app root, the content pages are in sub directories.
Have you tried putting the "~" in your href...
<link href="~/Css/Site.css" rel="stylesheet" type="text/css" />
I've found that sometimes Visual Studio sometimes doesn't know how to map up the paths to the css file, depending on where the master file is and where the web content page is, so adding the ~ to the path helps the referencing to just start at the site root and move forward.
Figure it out. I was running Visual Studio 2008 RTM.
The css issue is a bug in RTM that is fixed in SP1.
Link to VS2008 SP1 Patch Notes
317251 - When you link to a .css file in a master page by using the ~/ syntax, child pages cannot access the .css file.
Is the css file in your visual studio project? I have had similar things happen when the css file is exists physically in the correct place on my machine, but is not referenced in the visual studio project.
If it is not, then adding it to the project should resolve the issue.