I have just installed windows 7 and I'm trying to get my MVC application that was working in IIS 7 working in IIS 7.5.
The problem I have is that when it tries to load any static files (css, gif, jpg...) it requires authentication. So if I try to go to:
http://example.com/Content/site.css
It redirects to:
http://example.com/Account/LogIn?ReturnUrl=/Content/site.css
I ended up finding the problem. It seems that i need the IIS_USRS & IUSR accounts to have read access. I'm sure in vista i only had the IIS_USRS account.
For me it ended up being specific static content files that required authentication, while other static content files did not require it. Turns out that those files were green in Windows Explorer. I went to properties, Advanced, on the files and turned off "Encrypt contents to secure data" and my problem was solved.
It looks like you've messed up with something.
If you take the ASP.NET MVC template application (the one created when you start a new MVC Project), it won't require authorization to download static content.
If you provide more information, like your routes, or something else, it will be easier to understand your problem and find a solution for it.
Related
I have some Problems about deploying an MVC-site.
What I did:
Install Windows Server 2008 R2 SP1
Add the IIS 7.5 Feature
Install .Net 4
Register .net in the iis, using "aspne_regiis -ir"
Add a new Application at the Default Web Site
Choose my application
Choose the DefaultAppPool
call up localhost/test in the IE
The Problem:
The Site is not correctly presented
e.g. The text is not presented in the right colors but only in black
there are no Images shown
the dll's, located in the applicationfolder are not used
Here two pictures what it is supposed to look like and what it actualy looks like
what it looks like
what it is supposed to look like
I used different "how to's" about this topic but could not find my mistake.
So what do I have to do to display the Site correct?
Tanks.
An Workmate found the Answer. The StaticFileHandler for .css (or other static file types) was missing and needed to be included.
I am working on ASP.Net MVC 2.0 application with .Net framework 4.0 and IIS 6.1 (Windows 7).
When I created virtual directory for my application, the URL routing working for all server side actions. But it doesn't consider static content path like images, scripts and style.
Please help me ASAP.....
UPDATE:
Hi David Thanks for your timely reply.........
Please note the following sample:
I have created a MVC application with the Controller named as Home, inside the controller I am having a action named myhome when I accessing the routed path like localhost/Home/myhome, its accessed fine. Suppose I have some images on the view page. Those images not shown. Because of invalid path. But the same working with Windows 2008 R2's IIS7.0 and run directly from Visual Studio 2010. Only it didn't work on Virtual directly....!!
Are you hard coding paths with a leading slash? If so, stop and use Url.Content() instead. That will automagically handle your virtual directories.
Not much information to know your exact problem but something you can check is if "Anonymous authentication" is using your application pool identity.
On IIS7 double click on Authentication feature for your site and then "Edit..." (right click on "Anonymous Authentication) and change to "Application Pool identity" instead of IUSER.
I'm not a web admin, and I'm new to IIS. So, I'm looking for advice.
My MVC application (e.g. fooapp) is the default application for my site (e.g. foo.bar). I used IIS Manager to add the site to IIS7. When I import the application, IIS Manager wants to put it in it's own directory (/foo), and tells me I shouldn't put it in the base (site) directory. This means that to get to my default MVC view, I have to enter the URL http://foo.bar/fooapp/. Needless to say, I want to get there via http://foo.bar/
I see 2 possible solutions:
Add a default page to the site directory that redirects to the MVC app.
Ignore the IIS admonition and load the app into the site directory.
My IIS7 knowledge is limited. I have played around with some options (such as HTTP Redirect). Since nothing changed, I obviously don't understand what I'm doing.
Anyway, if there are some considered "best practices" and/or other suggestions, please let me know.
Tbh, I'm not sure why the IIS manager is trying to convince you to add it as a sub app.. Maybe you just didn't do it right >_>
I've got a couple servers running with IIS7/7.5 and they have apps running in the root of the website.. No problem there :)
You might want to create a new website in IIS (right click on websites, choose "Add Web Site"), point the "Physical Path" directly to the folder your website's stored in, and set the Host name to whatever host you use (foo.bar ? :) )
This should work just fine )
In terms of deployment, if you use VS2010 I'd really recomment looking at Web Deploy.. It's a new addon written for IIS7, and allows one-click publish to IIS directly from VS2010. I'm using it on my site and it works flawlessly :)
Check out Scott Hansellman's talk about it, or check it out in the IIS website
I've create a web site on my local IIS 7 with my own ASP.Net MVC project on its root.
Everything is working fine except for the static content. Going to http://localhost:8080/Content/Site.css gives me a 404. I can see the folder on IIS Manager.
The content is served fine with the small development server you get when you run the application on Visual Studio 2008. Any ideas what might be wrong?
The problem was permissions. Even though when I create the IIS7 web site I told it to access the files as my user (it wouldn't work at all otherwise), for static file it was using the user of the application pool. Giving access to IIS APPPOOL\MyApplication to the folder where my project was fixed the issue.
How about
routes.RouteExistingFiles = true;
in your Global.asax?
Try going to http://localhost:8080/../../Content/Site.css, not sure if your original URL is matching a route.
Not really a programming question though.
I'm using Visual Studio's built in web server to test and EPiServer applicaiton. When I have the app running in IIS, if I hit the root of the virtual directory, EPiServer will take over and server the defaul page to me. Using the Visual Studion server (which I am doing for license reasons with the SDK), it always gives me the 'Directory Listing' view of my site. Does anyone know how to configure this web server to not allow the directory listing/browsing?
Additional Information:
This problme only seems to effect the root of the visual studion web server (i'll call it cassini from here on in). As an example, if I run a site from localhost:6666, then what I will find is that localhost:6666/en/ will work just fine and the EPiServer VPP will know what it is doing. If I use localhost:6666/, then the VPP never kicks in (or so it seams). It seems to me that when the root of cassini is hit, it checks to see if the page exists (which it does not as I have no default). If it decides that the page does not exist, then it serves up the directory listing, rather than 404. The first thing to do for me is to dispable directory browsing in cassini, then look at why the VPP is not being actioned correctly.
So I suppose the base of the question is: Is there a way to modify these settins in Cassini when it is Visual Studio starting everything off?
(EPiServer may be a red herring, but just in case, it's CMS version 5)
Further Update
I managed to get hold of the source for Cassini 3.5 and gave that a whirl. 3.5 works just fine and behaves like IIS in this instance. I.e. the lack of default document does not lead to a Directory listing, rather if allows the HTTP handlers to kick in and then EPiServer does the rest! So the question is, can I achieve the same in Visual Studios effort at a web server?
Make sure you have a ~/Default.aspx file. It won't render, but it's needed in cassini for the virtual path providers to get a chance to handle the request for '/'.
Of course, if you make it anyway you might as well use it for the start page :-)
Even if you could get the server to not show the directory listing, could you get EPiServer to take over?
EDIT: From comments
The fact that it works with /en/ makes me think this is something that Microsoft could fix. I suggest you ask the vendor if they have a workaround. If they do not, then please create a suggestion at http://connect.microsoft.com/visualstudio/. Be sure to specify details about EPIServer, URL to the vendor, etc.
Be clear that it works with /en, but you want a setting permitting it to work at the root.
Once you create the suggestion, please edit your question to include the link to the suggestion you create. That way, others reading your question can vote on how important they think this is.
The EpiServer part confuses me. However, if you are asking how to set the default page for the VS development server (based on the Cassini code), you're expected to do that in the project properties (right click on web project), Web, Start Action, Specific Page, foo.aspx.
I suspect the cassini/VS development server doesn't have a default page feature-- the source code for the cassini server (the ancestor of the VS development server) is on the web and you can check that and add a default page by building a custom version. And it doesn't have a very long list of other features that IIS has.
Which EPiServer version are you running?
Did you install it using EPiServer Manager?
There has always been some differences in the configuration between running the site at the root of a host name or as a (virtual) directory.
Check the site settings block in web.config and make sure you have a default.aspx at the project root.