Visual Studio 2010 - References to CSS and JS files? - visual-studio

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.

Related

Polymer won't render on IIS server

I made an empty project in vs 2015 with a basic component, but can't get it to work using IIS, I always get a blank page.
I am NOT using bower since I don't like it . I used vs's NPM to import all the files.
So, here is my setup in an image.
in my IIS I just right clicked the folder and set -> Convert to application, used the default integrated app pool as usual, and in the project I set it to use my IIS. The links works fine, if I type some text in the body it works.
What could be wrong?
I believe you will have issues with your structure. Most elements try to load Polymer in a link tag at the top of the component definition file ( tag-name.html) . Polymer expects every component to be within its own directory, as well as having the same parent. That being said, you could alter every file to look in the right location after downloading them all, or place all components, and the polymer library itself, into their own folders. A brief example:
App/
Scripts/
Polymer/
CustomComponent/
paper-material/ <-- downloaded paper component
This should allow you to not get 404s and multiple downloads of identical files.
The next issue is that you are using the Polymer 1.0 library but implementing it in the 0.5 API. Translating your element to 1.0 (including the conversion of elements into folders) would result in the following:
<link rel="import" href="../polymer/polymer.html">
<dom-module id="ad-nav" noscript>
<template>
<h1>Test</h1>
<template>
</dom-module>
This should straighten everything out.
I think the problem is you clicked "Convert to Application" in IIS. For regular HTML and JavaScript you do not need to click that option. Don't do that and it will work. Clicking "Convert to Application" in IIS assumes you want a .Net Application, not a plain JavaScript and HTML application. This changes file and folder permissions which caused your issue.

js and css filename being corrupted on publish with VS2013

I am publishing my Web App using the VS2013 publish mechanism. For some reason it has just started corrupting the js and css filenames. e.g.
From
<link href="/Content/bootstrap.css" rel="stylesheet"/>
To
<link href="/Content/css?v=puREEettBuwGkRK7y27hOQwXg4qvcAYRnG8wxc0gvnU1" rel="stylesheet"/>
This is only happening on publish to the live site. It works fine on publish to the localhost site. It looks like possibly some kind of versioning.
The defined bundles in BundleConfig are not being expanded, instead parsed with the above result.
Any ideas? I have not seen it before and its not showing up on Google searches. Thanks for any suggestions.
ANSWER:
For anyone else getting this problem - Once I realised it was the Bundles I found this which gave a lots of thoughts. However my specific issue was that I had installed Select2 via NuGet which had added a css directory in Content. As I was creating a Bundle pointing at Content\css these clashed. I removed the css directory and republished. Still didn't work. But when I removed that directory on the server manually it all started working again.

Visual Studio 2012 saying 'Unable to edit' when including remote CSS file

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">

TypeScript - Visual Studio - d3

I created a new TypeScirpt project, added the json file to the solution, changed the 'Copy to Output directory' property to Copy always.
When I F5 the project, the browser complains that it cannot find the resource somedata.json
If I run the python SimpleHTTPServer, load up the same html file, it works.
<script type="text/javascript">
d3.json("somedata.json", draw);
</script>
Thank you.
Have you tried using the full path from the root of the site to obtain the somedata.json file?
d3.json("/scripts/somedata.json", draw);
Replace /scripts/ with the correct path in your instance, but start the address with a leading / to make it relative to the root.
This may be related to MIME types that the server used by Visual Studio is allowed to serve. You can define such MIME types at web.config btw if this is an ASP.net project.
Also see this official example in case it helps:
http://www.typescriptlang.org/Samples#D3
Have you tried to run the project using ASP.NET Development Server?

MVC3 Intranet Application / IIS Express Not Reading Site.css

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.

Resources