I have a simple but script and css fashioned ASP.NET MVC Application, within the VS2008 Development server everything goes well, but when I bring it to IIS7 I experiment some ugly script and images issues.. Scripts are not found by relative paths (this expecially in the default routed page) and images too.
After some research and googlin' I found many examples and provided solutions, but anything really solves the problem, Someone says one solution soude be using the Url.Content method but I hate to use it because I lost all the javascript intellisense feature in VS2008..
I found too this issue maybe different if the mvc project is shipped in a root web site or in a web application.. I know in a root web site it could works because referencing relative paths like
<script src="../../Scripts/myScript.js" type="text/javascript" />
in a web application folder is resolved without the root.
Anybody has some suggestion or someting else? I Intend after to start something to build a sort of configuration "guide"..
Thaks in advance
It may have been me that suggested using Url.Content. If so, I neglected the other half of what I do -- wrapping a relative path in an if (false) block to retain intellisense. Below is a (full) example of how I handle javascript.
<% if (false) { %>
<script type="text/javascript"
src="../../Scripts/jquery-1.3.1.min.js">
</script>
<% } %>
<script type="text/javascript"
src='<% Url.Content( "~/Scripts/jquery-1.3.1.min.js" ) %>'>
</script>
Related
I started using ES6 javascript modules in my ASP.NET MVC application but IIS express is refusing to serve javascript file of type module in script tag. I'm getting 401 Unauthorized.
<script src="~/Scripts/index.js" type="module"></script>
When i remove type="module" from script tag then it works fine.
Are request filters involved? Can you please help me set them right?
I ran into the same issue in a pretty bare-bones Apache setup for personal use. I was pretty dumbfounded until I came across this.
Check out the small section titled "Server Considerations", which mentions the use of crossorigin="use-credentials" in the <script> tag. It sounded only vaguely relevant since I'm working exclusively on a local origin, but I had nothing else to go on so tried it on a whim and it worked.
I can't pretend to understand why, or speak to any unintended consequences, so I would suggest diving into those aspects before pasting this into deployment.
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
We have an ASP.NET 2.0 WebForms app that uses MS Ajax 1.0. It's working fine on all our environments (dev, test, IE6 VMs etc.). However, at the customer site the client side validation is not happening.
We're currently trying to eliminate all the various factors and along the way we asked them to get their page source and send it to us, and we found something interesting.
In our environment, our page has ASP.NET javascript in CDATA blocks:
<script type="text/javascript">
//<![CDATA[
. . .
//]]>
</script>
In their environment, the same code looks like this:
<script type="text/javascript">
<!--
. . .
//-->
</script>
This may be a red herring, but I'd like to eliminate it as the cause of the validation issues.
Does anyone know whether specific configurations/patches/versions of ASP.NET will make it do this?
It might have to do with how (or whether) the pages are being rendered as XHTML. In the web.config, look for a xhtmlConformance element. In your examples, the version in your environment would be proper usage in xhtml, but the version in their environment looks like legacy HTML, not xhtml.
Check to see whether the machine.config on the deployment machine is set thusly:
<xhtmlConformance mode="Transitional" />
It may be set to 'legacy' instead.
While adding the following line to my app's web.config did stop the JavaScript from being rendered in blocks, it didn't fix the validation issue.
<xhtmlConformance mode="Transitional" />
What did fix the validation issue was installing .NET 2.0 Server Pack 2 on the server. It seems that using s from the MS Ajax 1.0 library on .NET 2.0 can break your s unless you install SP2.
I am trying to run a simple ASP.Net Web Application/Site on Vista Box. Unable to run any JavaScript when I hit F5. However when I deploy the same to local IIS and call the application using IE8 this application works and the JavaScript executes.
Another observation, when I copy the URL (example: http://localhost:XXXXX/yyy/Default.aspx) to a new tab within the same instance of IE8, this same happens. JavaScript do not run.
But when I browse the same application using another instance of IE8 the application runs well, meaning JavaScript executes properly. where do I set it or override it. Please help
I am suspecting that its something to do with the Instance of VS2008 running on vista home premium, so in all the above failure cases I was running VS2008 as an Administrator.
Please help and let me know how to resolve this. Thanks in advance.
Had the same problem. Settings in IE9 had been modified.
Tools ==> Internet Options ==> Security Tab ==> Intranet icon ==> Custom Level Button ==> almost all the way down to the bottom, Scripting ==> Scritpting of Java Applets ==> Enable radio button.
In my case, it had been switched to Prompt. Stopped Cassini from executing Javascript.
And thank you to Mr. Matthew Ward for pointing it out to me! Almost all of the options are locked out for us, so I have no idea how this changed.
Odd thing is, running against the IIS server on my box, the javascript worked.
Couiple thoughts
1) your instance of IE8 might have JS turned off
2) path issues (as suggested by Jared)
3) the "local path" issue; some browsers block Js that appears to be running from disk (might be a setting in your IE 8 to fix.
My blind guess would be that there is some problem with the path to your javascript files. If you could post the .aspx file that has the javascript that isn't running it would help a lot.
UPDATE: Thanks for the comment with the html, you should consider adding it to your question.
This problem sounds like a timing related issue to me (and your html doesn't seem to have any issues) so here is what I think will help:
1) Move the following code to the bottom of the page.
<script type="text/javascript">
$(function() {
$("#accordion").accordion({ collapsible: true });
});
</script>
2) Don't use relative URLs for your script/css tags. So your <script> tags should look like:
<script src="/Scripts/jQuery/jquery-1.3.2.js" type="text/javascript"></script>
<script src="/ui/ui.core.js" type="text/javascript"></script>
<script src="/ui/ui.accordion.js" type="text/javascript"></script>
3) consider using a minified version of Jquery and the other script files to reduce load times for them. Also, you might want to consider using a CDN hosted version of Jquery (from google, or microsoft).
If none of these suggestions work I would suggest posting the HTML for the entire page into your question.
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.