Confused with IIS locaton of the virtual directory - asp.net

I have IIS 7.5 and when I go to InetMgr, I right-click on the default website and then choose Explore. I see:
C:\inetpub\wwwroot
So far so good and as expected.
Now I created a C# web application and created a virtual directory under the default website. I right-click and explore I see :
C:\CSharpTest\WebApplication8\WebApplication8
This is also can be expected. However, when I run the Application, pictures are not loaded since the WebApplication8 folder is not created in C:\inetpub\wwwroot.
I know .NET 2.0 VS 2005 does create the folder in inetpub\wwwroot. So under VS 2010 do I need to copy files manually to the Inetpub/wwwroot?
When the page loads I see an empty picture place holder. If I right-click on it and then choose properties I see:
http://aocalhost.com/WebApplication8/pics/a.jpg
Then If I put this directly into the IE:
http://alocalhost.com/WebApplication8/pics/a.jpg
I get an empty page.

Just found the answer after spending 5 hours googling.
I tried almost a dozen of solutions but what worked for me was to enable static contents for the IIS.(Use Add/Remove Software in control panel/windows features)

Related

PDF is not accessible through URL in IIS .NET Framework 4.8 app

I have a PDF file in a folder on a server within a IIS website app that I need to be able to open through a link/url, like below:
https://api.example.com/my-path/my-pdf-file.pdf
The PDF file is hosted in a folder of my IIS application. When I try to access it through the link, I've got a 500 server error.
I tried several things within IIS settings (URL Rules, web.config, mime-types), but nothing worked so far.
Any advice will be much appreciated.
Is the folder included in the project? You can't just add a folder outside of Visual Studio, but have to use VS to add that folder.
You can right click on that existing folder (which of course is a sub folder of your project) and check this setting:
So, in my case, I right click on UpLoadFiles.
If the folder ALREADY is included in the project, then you get a option to EXCLUDE the folder like this:
However, if the folder is not included, then you see this:
so, is that folder included in your project? You want to check above.

ASP Site - Updating Dlls on Change

When I make a change to the a aspx.cs page in my website and then build I notice that none of the dlls in the Bin folder are updated, the only dlls I can see in there are the references the web app uses. I want to bring across this one change rather than redeploy the whole site so where are the changes being saved?
I've tried various things like build solution, rebuild solution, build website, rebuild web site.
Is it possible my dll is being sent elsewhere? How would I go about finding out where?
In Solution Explorer, on root project node, right-click and select Properties. Click on the "Build" tab and look under "Output" section. Here you will see the actual output path and can change it to your bin folder.
In Solution Explorer, on root project node, right-click and try to Clean solution and then again build whole solution.

ASP.NET Website Administrator Tool in VS 2013

Is there a short cut method to open website administrator in visual studio 2013, other than the method specified below
http://blogs.msdn.com/b/webdev/archive/2013/08/19/asp-net-web-configuration-tool-missing-in-visual-studio-2013.aspx
By Windows Explorer, copy folder ASP.NETWebAdminFiles and all its content to your solution folder (root folder of your WebApplications).
ASP.NETWebAdminFiles exists in %systemroot%\Microsoft.NET\Framework\v4.0.30319\
%systemroot% usually refers to C:\Windows
On VS2013+ \ Solution Explorer Window, do right click on your solution name; go over Add, on expanded menu click on Existing Web Site... item.
On opened dialog, on left pane choose File System, on right pane browse to your solution folder and select ASP.NETWebAdminFiles then click on Open button.
In added web site, in folder App_Code, find and open WebAdminPage.cs then:
4.1. find class WebAdminPage , find method OpenWebConfiguration that has 3 parameters, replace last line of code with this:
return WebConfigurationManager.OpenMappedWebConfiguration(fileMap, path, "localhost");
you can use domain name or IP Address instead of localhost
4.2. find class WebAdminModule, find method SetSessionVariables, find first if block:
if (application.Context.Request != null) { ... }
inside if block, replace two lines of codes with these:
queryStringAppPath = "/";
queryStringApplicationPhysicalPath = #"D:\PHYSICAL\PATH\OF\YOUR\MAIN\WEB\APPLICATION\";
4.3. Make sure provided physical path ends with a BACKSLASH.
4.4. [NEW] if you going to run this tool on localhost, in class WebAdminModule, find method OnEnter then find first if block:
if (!application.Context.Request.IsLocal) {...}
make whole of block as commented text:
//if (!application.Context.Request.IsLocal) {...}
4.5. On VS2013+ \ Solution Explorer Window, click on ASP.NETWebAdminFiles, on Properties Window set Windows Authentication as Enabled then set Anonymous Authentication as Disabled.
4.6. Set ASP.NETWebAdminFiles website as StartUp Project then run it.
It works, I use it for my applications over Intranet and web.
Good luck.
After a long wait, here is the replacement for the ASP.NET Website Administrator Tool:
Thinktecture.IdentityManager as a replacement for the ASP.NET WebSite Administration tool
Since then, ASP.NET has introduced ASP.NET Identity and community member Brock Allen created IdentityReboot with some significant improvements and extensions. Brock Allen and Dominick Baier have gone even further and created Thinktecture IdentityManager. It's the beginnings of a nice bootstrapped replacement for the missing ASP.NET Website Administration Tool. It is nicely factored and supports both ASP.NET Identity and their alternative called MembershipReboot.
Hope this helps.

How do I prevent IISExpress & My Web Sites folders from cluttering up my My Documents folder?

I noticed recently IISExpress & My Web Sites folders are getting added to the My Documents folder on my Windows 7 machine. I recently installed VS2012, so I'm guessing that's the culprit, but I haven't been able to find anything on line that explains how to change these defaults, if possible.
Microsoft cluttering up my 'Documents' folder with all their programs' (junk) folders drives me insane as well. I have conceded somewhat by creating a Data folder under my Documents folder, where I am pointing all MS apps (and others apps such as Firefox's profile folder) to for all their (generally unwanted) folders, and with a subfolder created for each program/suite. At least this way I can easily back up all settings when I back up my 'Documents' folders.
Anyway, VS2012 installs IIS Express, which is what is causing these folders to be created. I have found two solutions for dealing with the unwanted folders.
Uninstall IIS Express. You can do this from the normal Windows 'Uninstall a Program' part of Control Panel.
Change the folder location that IIS Express uses, as follows. Be warned: anyone doing this risks causing problems with their computer if you don't know what you are doing, so you do so at your own risk. Please make appropriate backups along the way as well too!
a) Close Visual Studio.
b) Create a new folder for the IIS Express sub-folders:
eg. D:\My Documents\Data\Microsoft\IISExpress
c) Move the existing unwanted IISExpress subfolders (config, Logs, TraceLogFiles) from your My Documents > IISExpress folder to the folder created in step b).
d) Create a new folder for the My Web Sites folder, I suggest also under the folder created in step b).
eg. D:\My Documents\Data\Microsoft\IISExpress\Websites
Under this folder, create a website for the default IIS Express website (in case it "auto-magically" reappears it's ugly head again later on).
eg. D:\My Documents\Data\Microsoft\IISExpress\Websites\Default
e) Go to the newly located config folder at:
eg. D:\My Documents\Data\Microsoft\IISExpress\config, and:
i. Open the file applicationhost.config in your text editor (eg. Notepad).
ii. Find the node sites > site > application path > virtualDirectory path for WebSite1, and change the physicalPath value from %IIS_SITES_HOME%\WebSite1 to the IIS Express default website folder you created in step d).
Eg. %IIS_SITES_HOME%\Websites\Default.
Note that %IIS_SITES_HOME% points to your 'Documents' folder (this appears to be a "feature" of IIS Express, I can't find a way to change it, and it appears to be auto-configured when IIS Express starts up, which it does by using the applicationhost.config file).
Do the same for any other sites created by IIS Express.
f) Create a new registry entry pointing IIS Express to the new folders you created (partly explained by MS here: http://www.iis.net/learn/extensions/introduction-to-iis-express/iis-80-express-readme). FYI the registry key doesn't previously exist, as IIS Express uses a default of my Documents unless this key exists:
i. Open the Windows 'Run' box, eg. (Windows Key) + R
ii. Type regedit
iii. Navigate to key: HKEY_CURRENT_USER\Software\Microsoft
iv. *Right click* the Microsoft key (that you have just navigated to), and choose: New > Key
v. Type IISExpress
vi. *Right click* the IISExpress key that you have just created, and choose: New > String Value
vii. Type CustomUserHome, and hit the Enter key to save it.
viii. Double-click the CustomUserHome string to enter a value for it, and for the Value Data: field, type in the path to the new IIS Express folder you created in step b), for example: D:\My Documents\Data\Microsoft\IISExpress. Press OK, and you can now close the Registry Editor.
g) Reopen Visual Studio, and it should start using the new folders, as well as not create the folders in your Documents folder anymore. Yay!!!!!
FYI, when I did this all, I actually did it in a slightly different order (creating the registry key first), but this order was the easiest way to explain it all. Whether you create the key first or last shouldn't matter, as long as you do all the steps. Good luck!
A Tricky solution
Make a copy of your C:\Users\<user>\Documents\IISExpress folder
first
Create a symbolic folder called IISExpress inside the C:\Users\<user>\Documents folder using the following command
mklink /J C:\Users\<user>\Documents\IISExpress D:\IISExpress
Move all the content from your copied IISExpress into D:\IISExpress
Thats all
If you're just looking to declutter your Documents folder, one simple workaround is to set the unwanted folders to hidden so it's no longer visible.
You can do this by right clicking on the IISExpress folder > Properties and checking the hidden property at the bottom. The folder will still remain in your Documents folder but won't be visible to you. If for some reason you want to access these folders again, you can toggle hidden item visibility in File Explorer's View tab.

How to tell what page a dll refers to in precompiled ASP.NET site

I'm using a pre-compiled ASP.NET 2.0 site (i.e., copied to the server using the "Build->Publish Web Site" feature in Visual Studio 2005). I catch and log all errors which are usually quite detailed, but lately I've been getting the following error with no other information:
Could not load the assembly
'App-Web-rp2eml-j'. Make sure that it
is compiled before accessing the page.
Now, that 'App-Web-rp2eml-j' file should be a dll in my bin folder which was created for the pre-compiled site. My main question is, how do I tell what aspx page is looking for that dll? I've tried re-publishing the site, and even completely wiping out the site and re-publishing, but the problem does not go away.
When Googling the problem, most answers about this error message center around making sure IIS is set up to use ASP.NET 2.0 instead of 1.1. This is not my problem.
NOTE 1: The site all seems to work, but obviously there is (at least) one page that is broken which I cannot find.
NOTE 2: The file name above should have underscores instead of dashes, but SO's markup is changing the text between the underscores to italics.
Does the mentioned dll exist in your bin directory? You italicized that portion so I suspect that it doesn't. That could mean that the error is referring to a dll in the Temporary files folder.
This problem can occur if one or more of the dlls in the ASP.NET Temporary files folder are corrupted. Sometimes ASP.NET does not refresh files here if there are no changes in the dll residing in the virtual directory. It happens every once in a while on my server.
My solution is as follows:
Stop IIS services on the server for a minute or so.
Navigate to the ASP.NET Temporary files folder (usually located at "%windir%\Microsoft.NET\Framework\\Temporary ASP.NET Files\MyApplicationName") and clear all files within the folder.
Publish and upload my site to the configured virtual directory.
Restart IIS and other services.
This simple 4-step process has worked very well for me in the past and may be worth a try for you.
To answer your basic question, however, there are two ways to "reverse engineer" a dll:
Load it up in ILDASM and check the contained classes.
Use Reflector to save all the class files contained within the dll to a folder.
However, I doubt if this will solve your problem because each dll could contain many class files and you would not have a clue as to "which ASPX page is looking for that dll".
Maybe you can catch more detailed information on the error with the Global.asax event Application_OnError, so you can watch the stack Trace.

Resources