IIS Publish project not displaying images - asp.net

I have a website that runs on IIS on an internal server.
It display fine when running from my local host. however, whenever I try to publish to my dev server, the images don't work.
And It looks like this
My first thought was that the images were not being transferred to the server. However I discovered this wasnt true, as I remotely connected to the server and found the images.
When I inspect the page, I get 404 errors for all the images. But the path for them seems correct. Goes to the properly named 'img' folder
I thought maybe it was a permissions issue with the images folder as indicated by this post
Images not showing on published ASP.NET MVC Website
So I added
<location path="img">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
And this did not change anything.
I checked to make sure none of the images in question were Encrypted through windows with the 'Encrypt contents to secure data' option under advanced image options.
After some more searching I came across this post,
http://blogs.msdn.com/b/ajay_pathak/archive/2011/08/06/website-deployed-on-iis-7-5-not-showing-images-and-css-files.aspx?CommentPosted=true#commentmessage
But i already have StaticFile enabled.
Finally I found this thread
CSS, Images, JS not loading in IIS
That suggested making sure anonymous authentication was set to 'application pool identity' instead of 'specific user'. I changed this and once again nothing has happened. I'm banging my head against a wall with this one. Please help.

So as it turns out there was a folder structure issue.
Was deploying from an svn where the folder structure was placed in another project incorrectly. As a result the 'img' folder was actually in a different location then specified. Once I cleared this up and properly nested the project, my issues vanished.
Thanks for the help everyone.

Related

IIS website paths behave different when accessing the site from outside the network

As the title states, I get different behavior on my website when I try to access it from the internet, as opposed to accessing it from the local network, and I cannot figure out why. I know it is because IIS is trying to serve me content from the parent application, but I don't know how to fix it.
Let me try explain: I have a website (not a web application) that I deployed to an existing IIS site, and then converted it to an application. If I access the website from the local network (<hostname>/path/to/site.aspx) then everything works fine, but when I try to access the site from the internet (<domain.name>/path/to/site.aspx) then it breaks, and I have the mappings set up correctly for the domain (it works on the parent application).
Initially it couldn't access the Site.Master page, saying the file cannot be found at <Site Parent Folder>/Site.Master (Instead of <Site Parent Folder>/<Current App>/Site.Master), so I had to change the master page reference on the ASP page from ~/Site.Master to just Site.Master And that seems to have worked for the master page only. It now gives me an error about being unable to find my classes in the App_Code directory (The type or namespace name 'MyClass' could not be found. Are you missing a using directive or an assembly reference?) so I'm suspecting that it is still trying to reference those from the parent directory.
Any ideas on how I can fix it so that it references the current application's directory instead of the parent app's directory?
Thanks in advance.
Ensure that your deployed website is running as a sub-applicaiton under main IIS site.
In your main IIS website update web.config and wrap system.web section with location element with inheritInChildApplications set to false
<location path="." inheritInChildApplications="false">
<system.web>
…
</system.web>
</location>
You can read more about it here

Change to web.config on server is not going into effect

when I debug my website locally using Visual Studio, the change to the web.config goes into the effect without any problem.
However, when I make the same change to the web.config on my server host (running IIS 7.5) it looks like the site is still running off the old version of web.config when I load it up in my browser. The new changes aren't applied.
I have tried stopping and starting my site's application pool on the server using IIS Manager, but still no change. I've also tried stopping and starting IIS, which isn't working either.
The change I am making to my web.config involves removing entries in the block to allow and deny users.
It is currently set up to prompt for credentials, and if valid, the site is accessible. If not, access is denied. The change I am trying to make is to allow access to all users and not prompt them for their credentials.
BEFORE:
<authorization>
<deny users="?" />
<allow roles="admins" />
<deny users="*" />
</authorization>
AFTER:
<authorization>
<allow users="*" />
</authorization>
What is the reason for this?
You have to reset IIS. Just open command prompt and run IISRESET and you should be good.
I have found that if I attempt to modify the Web.config directly through the file system (on an IIS server), my changes fail to be saved, and thus, are not applied. This is what I have found works for me, provided you have access to IIS on the host server:
NOTE: These instructions are based on IIS 8 on Windows Server 2012, but may still work for IIS 7.5.
Go to the IIS Manager on the host server
Drill down in the Sites until you find your application
Using the Features view, double-click the Authorization Rules
Use the Add Allow Rule... and Add Deny Rule... link in the Actions panel (on the right) to configure all your authorization rules.
This process updates the Web.config for you. If you need to edit or delete a rule, click on the applicable rule, then click the Edit... or Remove link in the Actions panel.
I hope this helps.
Are you deploying,publishing or copying? Make sure that your debug and release settings are the same. There are also instances when the virtual directory is not setup correctly and the correct webconifg is not loading.
Copy the web.config file from your server and place it in your local machine and modify according to your requirements. And then delete the web.config file in the server and copy and paste the modified web.config from local machine to server.
This work for me, but for me connectionstring was the Issue.
From MSDN - Web.Config
Any changes to the web.config file will require restarting the "Microsoft IIS Administration" service to take effect.
Maybe, maybe and maybe it help some one. I have the same problem. with IIS reset not work. with recycling AppPool not work. Maybe your drive have not free space.
This work sometimes after I delete some unwanted files. but I think important reason is Permission. we must use Editor like notepad or Run editor as administrator or web.Config need permission to change and then change Web.config. then Save.This works for me.
For me the problem was that I was building multiple solutions in the Azure DevOps pipeline and the deploy.cmd took the first web.config file as given. Therefore, I had changed the wrong web.config and the solution was to build via the csproj file and not via the solution.
Hope this helps somebody! :-)
You have to do following action
Click the BUILD menu
select the Clean Solution
after then
select the Re-build Application
Published the files (codes)
Above this action done, It is working fine without issue.
Reflecting changes in IIS services

Windows 8 IIS does not load stylesheets and images in asp.net app

I just installed Windows 8 on my computer and tried to load my ASP.net application. The page loads with no problems. But none of the images or stylesheets that are located in the App_Themes directory load. I do have a separate folder that has images in it and they do load. I think it is some security issue but I can't find out what it could be. If I deploy the site to my dev 2008 R2 box then the site loads correctly, but it doesn't load correctly on my Windows 8 box.
Some examples of my links are:
<link href="../App_Themes/Debug/style.css" type="text/css" rel="stylesheet" />
The above does not load.
<img id="ctl00_imgCompanyLogo" title="Header Logo" src="../Images/EmailImage.aspx?ID=6C633997-065C-44AD-9839-B754005B7995" style="border-width:0px;height:50px;width:220px;margin-left: 10px" />
However, this one does.
Note: No errors are loaded on the page the files simply don't load.
Update: I should also note that this did work when I was using Windows 7 to write my code.
Update: I added a html page to my application and right clicked on that and that page didn't render. However, if I create a new project, the pages render perfectly.
Update2: I think I found the root of the issue but I don't know what to do about it. If you create a new project on a Windows 8 machine then change the project so that it uses the virtual directory not IISExpress (use the Project Url) then none of the stylesheets load and the images won't load as well.
I had a stupid moment. I didn't check the Static Content check box under the Common HTTP Features group of the IIS configuration.
What worked for me:
Turning on all the features under Common HTTP Features. I did not check this while installing Windows 8.
Please refer this article:
http://gurustop.net/blog/2009/10/12/funny-problem-windows-7-iis-7-5-images-css-not-showing/
Are you running the application through Visual Studio or have it setup in IIS? If you are using Visual Studio to run it, by hitting F5, then you can try this in the web.config to allow anonymous users to access that folder:
<location path="App_Themes/Default/MyFile.css">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>

Same website different port Javascript and Stylesheets

I've a website running under IIS7. Everything works fine with this website. I've copied the directory and created a clone website on a different port. When I browse to the new website on the different port, I do not get any of the style settings until I log in -- then all appears normally.
The problem appears to do with the ASP.NET Membership/Authorization. I have a web.config in the subdirectories to allow all users (web.config) but the clone website is not using them even though all the config, directories, etc are the same. Only the port is different or non .config settings that IIS 7 uses.
I've discovered the problem but not the whole answer. The directories needed the IUSR permission to work but the original website doesn't have those permissions. It only had IIS_IUSRS. IF anyone can fully explain this behavior and how to fix the problem without granting IUSR then I will award the bounty for that answer.
The answer should be fully explanatory.
One potential issue would be with authorization settings in your config.
Look for something like this:
<location path="MyResourcesFolder">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
The above example would produce the effect that you've described assuming that your resources (css, jscript, etc) were located in a folder named MyResourcesFolder. Check the web.config that's in the actual website and not necessarily the project. This is because your website config may not be the same as your project config if you are using config transformations.

ASP.NET Localization Issue

I have succesfully added localization to my website. Came next day and it does not work. After reading alot of posts and did some troubleshooting my self. I found out that the Page ignores the page.aspx.en-US.resx. Because I dont have a standard resx for the page it shows the label caption i have in the designer. I just took out the en-US and made it the default( page.aspx.resx). The page correctly displays the strings that are in the resource file.
I have used the tutorial from MSDN and the same tutorial you can find it All over the internet I even contributed to te tutorial on MSDN. when you are using Authentication or Impersonation you must grant access to the APP_LocalResources folder through the web.config
<location path="App_LocalResources">
<system.web>
<authorization>
<allow users="*">
</authorization>
</system.web>
That I found out yesterday and solved the problem, but now It does not use the page.aspx.en-US.resx , unless it's the default I find it very strange. Does someone has the solution or suggestion?
I found the solution to my challenge. In order for the resource files to work you have to have a default resource file in combination with the other resource files e.g.:
default.aspx.resx
default.aspx.en-US.resx
default.aspx.nl-NL.resx
Even if you have only one language and you want to use resource files you have to have the default resource file for it to work, otherwise it will ignore any resource file you may have under the App_LocalResources.

Resources