IIS caching redirects seemingly without reason - c#

I am working on an ASP.NET webforms application that is being deployed to one of our internal IIS servers.
When I run the website on my machine using IISExpress it runs fine, can access the admin directory, however whenever I deploy to the server I can no longer access the admin directory and it just redirects me to the login page.
I have no code anywhere that should redirect me to the login page, even going so far as to delete the directory and it still redirecting, which would lead me to believe its a browser caching issue. After clearing the browser cache same thing happens, redirects you to the login page.
Another weird thing is that it only does it based on your website login account, when I log in using my actual account it allows me in, but whenever I use a test account with different roles it then redirects me.
I have checked all the usual culprits, HTTP Redirect, Output caching, temp ASP.NET files, master config and the sites own web.config to no avail. I have tried restarting the website and the application pool to no avail, and I can't restart the actual server/iis instance since there are other websites running that cannot be shutoff.
EDIT - Upon renaming the admin folder to admin2 it is now working without issue, so its definitely something to do with IIS. There be ghosts.

Related

Can read file from local computer, but not from IIS server

I've got an MVC site that i've published to a remote server running IIS, but I've got a problem with the site where I can upload documents to a folder (on that server, within the site header folder) via the site, but I get an "Access is denied" error whenever I try to read that same document.
At first I thought it may have been a simple permissions problem, but I checked the security on the folder and it's showing full control to domain users on it, and when I run the project locally through Visual Studio I can open it up without any problems.
I assumed it may be something to do with the context of the site running under IIS, but I don't know if the changes need to be made in IIS or on the folder permissions themselves.
Can someone help?
EDIT
I'm opening the file using Process.Start like:
System.Diagnostics.Process.Start("FilePath");
EDIT 2
I've edited the app pool that the site is running on and set it to allow the process to interact with the desktop, but this has not worked. I have also tried setting the App Pool to load the user profile based on suggestions I found elsewhere but that has not worked either. The only other suggestion i've found is to set the App Pool identity to "Local System", but people have said this is a security risk so I don't want to do this unless necessary.

Windows Authentication and web.config renaimg

We are facing a strange issue with ASP.net Application using Windows Authentication and required some expert advice for resolution. Below is the detail scenario
1- Application-1: deployed on IIS on its own App.pool, Call the default page and provided the User ID and Password on IIS windows login screen. It successfully logged in=>No Issues.
2- Application-2: Create a new virtual directory on Same IIS and copy the web content of Application-1. Call default page and provided the User ID and Password on IIS windows login screen, It fails and Keep prompting Login screen
3- Rename the web.config in Application 2 to anything. e.g web123.config.
4- Call the Default Page of Application 2. It shows error which is obvious as IIS unable to find the web.config.
5- Reverse the name of web config from web123.config to web.config in Application 2.
6- Now call the application 2 again as per step 4, and it works.
It seems the IIS is overwriting some thing once we call the application with no web config as in step-4. But What and why it is not working at Step 2, where as technically we did not change any thing in web.config.
I'm not sure why renaming the web.config makes this work for you, but I have had this issue with duplicate websites on the same server having conflicting cookies. Without renaming the web.config can you do this and change the cookie name and see if anything changes?

PhantomJS runs fine as me, returns blank page when running under IIS

I'm running an ASP MVC3 website that spins off a new process that runs phantom js, which calls a website and writes what it sees to a file. The IIS_IUSRS group has write access to the directory. If I run the script manually, it works fine. If I run it under IIS, it draws a blank page. Is there something obvious I'm missing? Is there a way I can become the IIS user to see what the error is?
Thank you.
Edit: I figured out how to get the status of page.open. The status is "fail". Works under my admin account, fails under iis account.
I am not an IIS user, but on Linux Phantomjs won't run through the server user (Apache user) and will give permission denied error. There is a workaround for linux where we need to create another bash file and provide it root access (admin access in your case). So in your case you are looking to run phantomjs through the admin user behind the scene. Sorry but I can't help more on it. The linux workaround is http://cisight.com/run-latest-phantomjs-with-shell_exec-php-on-ubuntu-11-10-oneiric/.

silverlight with forms authentification - redirect to login.aspx

I've got a Silverlight Application which uses forms authentication. I tried to deploy and run it on my new Test-Server but its really weird.
I activated anonymous and forms authentication.
When I run [serverip] I get redirected to Login.aspx (which doesn't exists) and I don't know why.
When I run [serverip]/Default.aspx I get a blank white page. Fiddler shows me, that the Default.aspx page gets loaded, but getting the embedded Silverlight xap File results in a redirect through to Login.aspx.
Does someone have any idea what I'm doing wrong?
I deployed the application via file system. Unfortunately the user "everyone" had no access to the ClientBin-folder. Giving "everyone" access to this folder solved my problem.

Adding C# web app to a web site with IIS6

I finished my very first C# project in VS 2008 and it is working well now. But now I need to publish this project onto my new website. This project is a web application that interacts with my SQL Server 2008 Adventureworks database on this same computer(XP Professional OS). I am running IIS 6.0 Manager, but I am a newbie to both IIS 6.0 and VS 2008.
I began by right-clicking the application in VS and selecting "Publish", but I've just selected File System, cause choosing Local IIS forces me to enter Username and password.
The problem is that I can't open this website from IIS without it prompting me for username and password. I have modified machine.config file several times in the processModel section, by setting username="D610-M\ASPNET", password="AutoGenerate". But this makes me enter built-in password when I try to view it. And I don't know what built-in ASPNET password is. When I cancel this password popup, it returns:
HTTP 401.1 "You are not authorized to
view this page."
And I've reset the ASPNET password several times. First I tried setting it to a password I knew, then I ran the aspnet_regiis command to reinitialize it. I also tried substituting other usernames and passwords, but none of them have worked. I even tried entering "SYSTEM" for username and AutoGenerate password, but even this prompts me to enter password. I have added the ASPNET user Read/Write/List permissions to all relevant folders. And I tried to create a new website pointing to http://localhost/[AppName], but this forces me to enter password. So no getting around that password.
I have modified Properties for Default Website in IIS: Home Directory pointing to my application in VS 2008 folder and Application Protection = Low. On Directory Security tab, I set username to D610-M\IUSR_D610-M and I checked "Enable anonymous access." I unchecked the Allow IIS to control password.
And I have read alot of MS URL's and other websites to see if I could answer these problems myself, but none of their helps worked either. This should be simple. I'm just trying to add my web application to my website. I know that my website works cause I installed a default website with basic HTML and it works.
What else can I try in order to add this web app to my website?
One important limitation to remember is that you are only allowed one website on IIS6 on XP.
If you have edited your machine.config you have introduced too many new variables into the equation to properly troubleshoot the problem (not that editing machine.config in itself is harmful, but it's an indication that there's a bit of shotgun approach to the problem).
You need to start out by wiping your slate clean and making sure that you have an otherwise working system. Browsing an HTML page does not prove much as running HTML and running ASP.NET are like apples and bicycles.
The best that I know of for doing this is uninstalling and reinstalling IIS and whatever .NET framework you are on. If you are on 3.5 you should do this for both two and three point five. If you can you need to put machine.config and every version of web.config (except the one in your web app itself) back to their defaults. There is nothing there you should need to edit run an ordinary ASP.NET app.
Once you think you have a tabla rasa and can browse an html page, then change its extension to .aspx and see if you can still browse it.
My last suggestion for today is:
As a poster above said set your ACLs on the folder where your website is (typically c:\inetpub\wwwroot) so that the group "Everyone" has "Full Access". Don't leave it this way, even on your own machine, but it takes file permissions out of the equation. If you are still having problems let me know, but basically you need to start from a "known good" state if you ever hope to get this problem resolved.
I am not sure if this is it, but.... I have seen this error myself and it is usually caused by not having the ASP.NET version set to 2.0 in your Website properties under the ASP.NET tab. This setting is often defaulted to ASP.NET 1.1 which would cause this error to occur. Note, that even though you are using Visual Studio 2008 the ASP.NET Version is still needs to be 2.0 in IIS. I would double check this setting.
Usually, I recommend the initial build to be to a location in C:\ (example being C:\MyFirstApplication). You also need to make sure the "Network Service" has permissions to that folder. Placing the application in the projects (or whatever) folder in your personal documents list is asking for permissions and access issues. Try that and see if it works!
You need to set root level folder permissions on your web site. Navigate to the folder that holds your web site, right click, permissions, security tab. Make sure that you have asp.net, anonymous user, Internet Guest Account (computer\iuser_{something}) and network service in the allowed roles.
As an aside I suggest that you pre-compile your site before posting it to your web server. This is a security precaution and a performance booster. Getting into this habit will be a good thing for you in the long run. It keeps people from tweaking the code on the server. There is a good utility here to make this easier: http://www.west-wind.com/tools/aspnetcompiler.asp
I believe this is pretty much the same as the question posed by him earlier here

Categories