I first created an MVC3 Intranet web application in Visual Studio 2010 Professional.
It worked just fine.
I then right-clicked on the application and chose "Use IIS Express..."
I also edited the application properties and disabled Anonymous Authentication but enabled Windows Authentication.
Nothing more. This is a bare-bones, default skeleton of an application that I want to start from.
Now when I run, I first get a pop-up window to login with my username and password. This is just as I expect. However, when I log in, the "Home" and "About" pages are not formatted correctly. It looks like IIS Express isn't reading my Site.css file.
How do I fix this?
Thanks,
- Paul
The default links for the style sheets typically use the ../../ directory navigation. When you're on a real webserver, those links typically fail 'cause now you're in a different folder setup. An easy way to correct them is to use:
<link href="<%: Url.Content("~/Content/style.css") %>"
rel="stylesheet" type="text/css" />
The url.content part will rebase the links to the current directory and will link up it's content correctly.
Hope this helps some, and good luck on your project.
Related
I have included the CDN of the bootstrap CSS in my project. Everything works absolutely fine, except when I type
<div class="
Then Visual Studio pops up an error saying:
Unable to edit
'http://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap-theme.min.css'.
here`The style sheet must be part of the current project and the project must be a Web Site or Web Application project
I can hit OK to dismiss these errors, and then everything works fine as well - it reads the CSS classes and populates Intellisense and works correctly when I build. But why is Visual Studio trying to edit the remote CSS file? How can I tell it not to?
I was having the same problem and a little search brought me to the following page:
http://forums.asp.net/t/1586914.aspx?Unable+to+edit+CSS+file+
In a nutshell: Add a fake parameter to the end of your CDN URL to get rid of your errors. This also makes intellisense work correctly.
Example:
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css?parameter=1" rel="stylesheet">
I have a fresh File -> New Project MVC3 application. When i Publish it and run it in IIS7.5 everything in the Contents folder seems to be inaccessible. Every other folder seems to work fine.
<img src="#Url.Content("/Content/1.png")"/>
<img src="#Url.Content("/Scripts/1.png")"/>
With this code Sample the top image is missing but the bottom one displays fine.
I have tried it in IIS express and everything works fine. Everything works fine when i start debugging the Site in IIS from Visual Studio.
It doesn´t seem to be an file access problem since the whole app folder has permissions for the IIS app pool and accessing content in the Scripts folder works.
Thanks for any help you can give.
You forgot the '~' (the app root path)
<img src="#Url.Content("~/Content/1.png")"/>
<img src="#Url.Content("~/Scripts/1.png")"/>
This one has me stumped.
I have an MVC 2.0 environment in a S#arp layout, everything works great, and I have Intellisense working in my aspx file (for things like HTML helpers and Model properties)
As soon as I add the line:
<identity impersonate="true" userName="xyz" password="abc" />
To my web.config, I lose Intellisense on my aspx files!
Does anyone have any idea of why this is happening? Or have any experience with this?
Ok, finally figured this out.
It looks like the impersonated user needs write access to a folder within the S#arp folder structure. I still don't know which since I assumed \bin and that didn't work.
So, give the impersonated user read/write access to your project folder and intellisense is back!
I am working locally in a web site project with vs.net 2010.
How should I reference script and css files that are not in the immediate web site (application). The site will be deployed to a virtual directory (application) under a root site. The script (js) and css files are standard and are maintained in a vdir under the root site.
These are the requirements..
- the references must resolve when I push F5 (browsing to the site with built in iis server(cassini)
- within vs.net and in design view I need the references to the css files to be working so that we can view the styles correctly from within vs.net (as well as when we push F5, or if we setup a local web application on our IIS on our workstation)
Is this possible?
thx
No problem. Just use a fully qualified reference. (Absolute path)
<LINK href="http://www.somedomain.com/css/glob.css" rel="stylesheet" type="text/css" />
You've really got two choices: relative path, or absolute path. There's not a good compromise between these. From what you've described, relative path is not a good choice.
You will need to replace http://www.somedomain.com/css/glob.css with the servername and full path to the CSS that you want to reference. And, you will need to do the same for JS references.
I've created a couple of Office plugins. The plugin shows a set of html files installed on the clients computer. The plugin uses a COM-accessible assembly which shows a WinForm with a WebBrowser on it. The plugin makes the WebBrowser navigate to a file on the clients computer. The assembly is also used in other programs to show the same information.
When showing the local html files using a 'normal' browser (e.g. double clicking a file in Windows Explorer) the browser popup a security warning about running active content. This is because we have some javascript in it. This warning is supressed by setting the 'Allow active content to run in files on My Computer' in the Internet Explorer settings. This solves the issue using a 'normal' browser.
Funny enough the 'active content' warning is not shown when getting the same file using a Word/Excel/PowerPoint plugin. It calls the same assembly, using the same WinForm and using the same content. Despite the setting 'Allow active content to run from My Computer' being false, the content is shown without a warning and the javascript is executed.
Now, the problem and the real question is that Outlook does the reverse. No matter what I use for 'Allow active content to run from My Computer' the browser warning about the active content in the html file is shown. When I confirm the message and allow the scripts to continue, the javascript runs fine. So, even when I set the 'Allow active content to run from My Computer' to true, the warning is given.
I've gone through all (sort of) relevant settings in Outlook, but nothing helps.
I assume that Outlook is using some kind of private context for a webbrowser (probably because it is using a webbrowser object internally).
The real question is: how can I make the Outlook plugin respect the IE settings?
(I understand this is a long story and maybe not clear enough. Please let me know if I have to elaborate more).
I couldn't get rid of the security warning without lowering the security setting. And that is not an option: we are talking about a project that will be installed on millions of computers.
I decided to go another route. Let's see if we can make the browser trust the html pages. So, what to do to get rid of the 'Active content' warning.
First I investigated what exactly triggers the warning. That was easy: any tag in your html file will do. And I need script, so removing that isn't an option. But, when hosted from a website, the scripts run fine and don't suffer from a warning. So, I investigated if it is possible to run my files in the Internet-context.
I found out there is a way, at least for IE (which in my case is sufficient). If you save a webpage as a complete HTML file from IE, the browser adds a comment to the html to signal its origin. Something like: . If you later open that stored html file, the file is shown in the Internet context.
So, I tried adding to the html file. And, voila, the file is opened in the Internet context. The security warning about active content is gone and the scripts are executed fine.
But, that raised another problem. We have a couple of window.open statements in the scripts and using that causes he cross domain browsing problems that in recent IE versions are blocked. Even if you use a relative path in the window.open call, if fails and you end up with a blank window.
In our case, we can (probably) decide to get rid of the window.open calls. But, if a reader ever finds a solution for using window.open in this scenario, I would be very happy if you let me know.
So, for now: case closed...
Internet explorer use Mark of web in such cases
<!-- saved from url=(0014)about:internet -->
<!doctype html>
<!-- saved from url=(0023)http://www.contoso.com/ -->
<html>
<head>
<title>A Mark of the Web Example.</title>
</head>
<body>
<p>Hello, World</p>
</body>
</html>
More info from here
https://msdn.microsoft.com/en-us/library/ms537628(v=vs.85).aspx