Static content not loading after deployment to IIS 7 - asp.net-mvc-3

I'm having a problem where my style sheets and images are not loading after I deploy my site to IIS. It works fine in visual studio and local IIS.
I think it is trying to authenticate the static content because the css sources are showing up as LogOn?ReturnUrl=%2fContent%2fstyle.css in Chrome inspector. If I inspect the source code of the css it is just my logon page.
I've ensured that the server is set to serve static files and the IIS user has access to all of the files.
I've also tried adding the following code to my web.config:
<authorization>
<allow users="*" />
</authorization>
I found this in a similar stack overflow question but it did not work.

I figured it out. I had to set Anonymous Authentication to use the app_pool identity.

Related

Umbraco Back Office not showing tree properly

I'm experiencing a strange issue with the umbraco back-office. The umbraco version is 7.5.3. Inside umbraco back-office when i try to open a node of Settings or Users tab , either templates, partialviews, stylesheets, etc, automatically a .aspx file is generated and downloaded and the node gets loading infinitely. For example clicking Create in templates a file create.aspx is generated and downloaded. Clicking in any of the templates a file EditView.aspx is generated and downloaded.
In chrome console appear the following:
jquery.min.js?cdv=865237568:3 Resource interpreted as Document but transferred with MIME type application/octet-stream: "http://localhost:54531/umbraco/settings/Views/EditView.aspx?treeType=templates&templateID=3289".
The same problem happen both in back-office local environment and back-office production environment. Fortunately the page in production has not problem but I can't access into the nodes into the back-office. Please, any help would be very appreciated. At the end, an image of the logs. Any other information required about the issue please let me know.
Tracking in version control I realized that I had deactivated the ImageProcessor module by commenting the following line in web.config:
<!--<add name="ImageProcessorModule" type="ImageProcessor.Web.HttpModules.ImageProcessingModule, ImageProcessor.Web" />-->
but this line:
<add name="StaticFileHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.StaticFileHandler" />
which was added previously when I installed ImageProcessor.Web.Config also was necessary to comment it. so I commented too and the problem dissapeared.

ASP.NET MVC - Can't log into the system using IE after publishing to server

I have a project created in ASP.NET, MVC 3, C#. It works in every browser when testing it on my dev machine, once published it works fine in chrome and every other browser apart from IE.
The problem - I am trying to login to my site but the web site just refreshes with the return url included in the url.
I have tried the following:
Removed helpers
Removed webMatrix
Added the following to the web.config:
<add key="enableSimpleMembership" value="false" />
<add key="autoFormsAuthentication" value="false" />
Checked my internet options settings, they are currently set to medium-low and Enable Protected mode, I have also turned this off and had no joy.
I have another web site that has been deployed to the same internal server and works fine
in IE.
Does anyone have any idea what would be causing this problem?
Here is my Web.config:
http://pastebin.com/0b5FBuTs
I am using IE9
THanks

ASP.NET MVC 3 Areas and multiple authentication in web.config

I have been attempting to follow this blog to get Areas working:
http://mstechkb.blogspot.com/2010/10/areas-in-aspnet-mvc-20.html
In the blog post, it identifies the ability to have authentication set per Area, e.g.:
<location path="Area1">
<system.web>
<authentication mode="Windows" />
<authorization>
<allow roles="role1,role2"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
However, when I try to create this in a new project in Visual Studio 2010 I get the following error when I run:
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
From what I can see this is because you cannot specify an authentication element unless it is in the top level web.config.
So it is possible to do what the blog post says? Can you have Areas with Authentication elements inside Location elements in the web.config?
What I have learnt about ASP.NET MVC, it's always better to set the authorization rules with [Authorization] attribute applied to individual controllers, because it is safer and more adequate considering the way routing system works.

Website default document denied by security restrictions?

I have an ASP.Net 4.0 website hosted at winhost.com.
The default document is index.html. In the browser address bar, if I enter
http://www.mysite.com/index.html
it works fine - I get the index.html page as desired.
If, however, I simply enter http://www.mysite.com
the site behaves as if I have requested a page allowed only to authenticated users, that is, I am automatically redirected to the Login.aspx page.
Obviously this is a major panic! It means that the normal, public facing portion of the site is no longer visible unless visitors are instructed to include "index.html".
In IIS, I have verified that the "Default Document" is index.html, and it is first in the list.
In the web.config, I tried adding
<location path="index.html">
<system.web>
<authorization>
<allow users="?" />
</authorization>
</system.web>
</location>
But that did not help.
This all happened when I converted the site from 2.0 to 4.0. I was so busy fixing all the other problems (ajax security, wrong versions of dlls, etc.) that I never noticed this problem. Seems like it should be simple to fix, but I am stumped. Thanks for any help!
Check the NTFS permissions for the folder, where your website is located. And compare it with "index.htm" file permissions. Some user account must be missing.

How to set cache expiry date

Trying to cache a large js file on the client browser. When I check firefox's cache information, it shows the js to expire on 12/31/1969. I'm using IIS6 and have tried adding the following code to the web.config:
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />
</staticContent>
Still the same. How can I get the browser to cache this file?
In IIS, right click on your Site node and click Properties. Go to the HTTP Headers tab, tick Enable content expiration and set an expiry time.
You may have to configure that in IIS, I'm not sure that IIS6 honors that web.config setting like IIS7 does.

Resources