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.
Related
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.
does anyone have any good links/tutorials about how to create a simple ASP.NET MVC website, and have it run against a Local IIS7 Web Server, instead of the default Visual Studio Development Server (aka Cassini).
Yes, i tried google, but i fail at getting some good keywords, etc.
Cheers :)
Here are my steps:
In IIS, Sites -> Add Web Site...
Fill in the name, whatever you want.
Set the physical path where your app is located.
In the Host Name option, type for example local.test.com
Hit OK
Then I update the hosts file located in $windir$\System32\drivers\etc
Adding the line
127.0.0.1 local.test.com
Don´t forget changing in the application pool of the created website the framework version.
I´m sure there must be other ways, I just follow this steps every time I want to create a new site in my local IIS and it works.
Good luck!
I have reading posts all night looking for an answer to my issue and haven't found anything that works for me yet. I am sure there is a simple way to do this but I haven't been able to discover it yet.
Details:
MVC 2 Preview
Asp.net 3.5 sp1 framework
VS 2008 C# web application
Windows Server 2008
IIS 7
I have the application running well through VS 2008 no problem. When I hit the play to run in debug mode it starts the ASP.NET Development Server the application loads fine and works as expected, great!
When I publish the application locally or to my web server both on IIS 7 the application doesn't run correctly. Some of the icons are missing and the google maps map is missing. When I view the source it appears correct at first glance, but I can see the paths to the images are looking for the MVC paths and it isn't finding them. It appears the app is running as a regular asp.net app and not an mvc app, maybe?
I also tried to just hit the full source code locally on localhost and the exact same issue is present.
So, I guess my question is how do I deploy a MVC application to run the same in IIS as it does through the development server.
PS The environments are clean and pretty much out of the box.
#user68137 is correct in saying that you need to use relative paths for the images.
I got caught out on this one too, and here's my previous SO question about it...
In short, you need to do something like this...
<img src='<%= Url.Content( "~/Content/Images/banner.jpg" ) %>' alt="Banner" />
Hope this helps!
I had the relative paths set, but what I didn't realize is when I deployed it to the server it went to wwwroot\subsite... I had the relative paths set to src="....\image.jpg" to get back to the root of the site. My error was that if the site is not in the root then the subsite drills back to the root to find the images and of course doesn't find them. Same thing was happening with the JS files. I used the Url.Content and it worked great! problem solved!
The interesting this is when running through the VS dev server with a subsite it still worked well and found the paths even though it shouldn't have. VS dev server <> IIS
Thanks for your help on this!
Simon.
Once you know the virtual path to the location you are deploying the project to, you should go into the project configuration in Visual Studio and add it to your project. This way the visual studio development server will use the same path structure as the deployment server. This will save you countless hours of work when deploying.
When you run your website through Visual Studio, every single request gets processed through the ASP.NET pipeline, including images, CSS and other resources. IIS by default only processes specific extensions (e.g., aspx) unless you tell it otherwise through configuration. Paths like '/content/images/yourimage.jpg' should work just fine...I suspect it's something amiss in your IIS configuration.
Another possibility which I've run into is any custom ISAPI filters you may have installed on the IIS server (e.g., ISAPI_rewrite). It's easy to set up rules in its configuration that lead to some very unexpected results.
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.
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.