Where does IIS look for files - asp.net

Can anyone explain, please, exactly how .net works. I create a web site in Visual Studio and publish it to a local server to a folder at
D:\WebSites\Project1
I create a web site in IIS and provide the address of the folder containing the files for the web site. When I publish the site, using 'fixed naming and single page assemblies', all the .aspx files go in the folder on the D drive and a dll for each page goes in the bin folder inside that folder.
I would assume that when someone wants to view a page in their browser, IIS retrieves the file(s) required from the folder specified, they get processed and turned into html and sent to the browser.
Recently when someone clicked a button on a page that calls a web service - a file not found error was reported. Apparently
C:\Temp\bx5tn2js.dll
could not be found. The thing is - why did IIS decide to look in C:\Temp for a file?
And, in the error message was a load of references to xml serialization. What is being serialized?

This file looks like the compile files that asp.net generates on compile.
This folder can be setup on web.config on compilation session with the
tempDirectory="C:\Temp"
If you do not have set this option asp.net is use a default folder that is usually inside the asp.net directory, inside the windows folder. But if you have set this, and this folder did not have the correct permissions, then asp.net fails to compile the project, and you can get a message like that.

Related

ASP .Net Web App not publishing .cs files and Database

I have a web portal app. I built it in Asp .Net. The app is now ready but when I try to publish it using Visual Studio, I only get the .aspx and .css files. It does not include the .cs files that have all the backend code and functionality, and it does not include the database either. The method I used for publishing the app was:
Right Click my project -> Click on Publish -> Select IIS,FTP,etc -> Select File System and provide Target Path -> Click Save.
It published the app at that targeted location. But, when I open that folder, I can only see the .aspx and .css files and no .cs files, as you can see in the following screenshot.
https://drive.google.com/file/d/15pecp8tbamjlWCm4rfV6M_zeW7zdUUB9/view?usp=sharing
At first, I thought maybe this is how it publishes the app, as this is the first time that I have tried to publish a web app. Therefore, I loaded it to IIS as it is, and tried to browse it. When I browse it, it loads the first page, that is a login page, correctly. But when I enter user credentials and try to login, it provides me with following error:
https://drive.google.com/file/d/1TIC0gE1tFpcne4bXaSsEVm8yiOPnIyOt/view?usp=sharing
I have underlined the lines by which I got the idea that the error is related to database and .cs files.
Please, if anyone can help me about this, it will be really appreciated. I have a deadline and I dont have any idea that how can I solve this problem.
Thanks.
When you publish your web application the visual studio compiles all your your cs/vb/class code into binary files (dll), this dll files can be found in your site bin folder, so you can't find the .cs file.
There are many causes of the network path was not found which are given:
1.Antivirus 2.Firewall 3.SQL Server Network configuration.
and please check if you have the port in the connection string "Data Source=x.x.x.x,1433".
More information about this error you can refer to this video:Resolving SQL Server Connection Errors
For a web application your .cs files are compiled into a DLL which will be in the bin folder.
The special App_Code folder can be created and the .cs files in there will no be compiled during publish and will be compiled by IIS on demand.

asp.net manual copy to server

So I just got a site hosted at hostasp.net. In VS I'm working with a web site not a web application. In the control panel on the host under my site I have folders (data, logs, wwwroot). My current project only has 1 javascript file, 1 aspx page, and a web.config. I placed Default.aspx & web.config directly under wwwroot. In VS my javascript file is in a subfolder named Scripts so I created this subfolder on the host site and placed my javascript file in there.
When I access my site I get "Server Error in '/' Application." error. What am I messing up here?
Also if I have a code behind file, where do I put that? Should it be compiled somehow? When I built the VS project it doesn't give me any dll for it or anything. Right now I don't have anything in the code behind but just wondering for later if I do.
If you are using Visual Studio:
You can certainly just copy the files to your live server. Your "code behind" files will be compiled at run time.
You can Publish a Web Site or Web application so you have the option to pre-compile (to dll) all your code (and will be in /bin folder).
If you want to remove the "guessing" of which files you need to "push" to your live server. You can publish to your local file system or directly to FTP. VS will pre-compile your Web Site or Web Application, and "collect" all the necessary files that make up your web site/application and save it in the folder/FTP site you designate.
If you chose to publish to file system, then all you have to do is copy/ftp (whatever) to your live site. You might ask why even publish to local (first) only to FTP it anyway? So you can get fully acquainted with how all of this works - the different publish options, etc. locally (which is essentially the exact structure of your production site).
Publish Web Site (VS):
Publish Web Application (VS):
The only time this may not work is when your host doesn't have the "bits" that you might have. E.g. not all hosts may have the latest/greatest from Microsoft, like say, Web API and all the assemblies it entails.
But again, the tooling can help with Add Deployable Dependencies...which does and when you publish, the dependencies are all "bin deployed" (meaning they'll be in the /bin folder):
Hth...

IIS 6.0 web application - Does the entire "website" need to be an "application"?

I had a website hosted in IIS. One small section of it needed asp.net. So I just right-clicked that section/directory and made it an application and a virtual directory.
Is that alright? Or does the entire "website" need to be made into an application and virtual directory?
The reason I ask is that when I try to browse to the aspx page in this "application", I am getting a parser error message "Could not load type...MyCodeBehindType" in the page directive, which seems to me to indicate that it is not finding the dll's, or even the code behind class files (which are clearly in the same directory).
EDIT:
If I do it this way, with only a subfolder of my website actually being a web application, where do I put the dlls? In a bin folder of the website the web application is within? Or in a bin folder of the web application?
Making just a folder within a website, an application, should be fine. I usually have to remember to change the version of ASP.NET from 1.1 to 2.x, that may be what's causing the error.
In order to test the configuration, start with a blank test page (blank.aspx) with just HTML. If the HTML shows up, you know IIS is serving .NET pages.
If there is a problem with ASP.NET not being correctly registered for IIS, you could try re-registering it. Open the following folder:
%WindowsDir%\Microsoft.NET\Framework\x.x.x\
and run:
aspnet_regiis.exe -i

Obscured URL in ASP.Net Webforms

I am working on a ASP.Net web forms application which I inherited from a programmer who has already left the company a few months ago.
The application is deployed in our intranet servers and user go the application via the url:
http://TestApp/App1/(12345abcde)/login.aspx
When I checked the IIS Server, the application's folder is only set to
\inetpub\wwwroot\TestApp\App1\
and from that folder, you could see the login.aspx file.
I'd like to ask what IIS settings did the previous programmer tweaked so that the URL is a bit obscured, where the imaginary(?) folder named (12345abcde) has been inserted. Which settings do I need to check for in the IIS for this?
Another question is that in the login.aspx file, the following can be found: Codebehind="Login.aspx.vb", but the same file Login.aspx.vb is not on the application's directory. Although I did see that there is a bin folder where a dll file resides. Is it possible that the vb code behind file is compiled into that DLL?
By the way, if there is an available dll viewer which I could download, kindly post the same so that I could inspect the DLL in the webforms app.
Appreciate your inputs. Thanks.
This comes from using cookieless sessions in ASP.NET.
Basically, instead of storing the session id in a cookie, it is passed as part of the URL, which makes the app usable even when cookies are disabled in a browser.
To enable/disable this feature, use the following web.config entry:
<sessionState cookieless="true" />
Regarding your second question: when you use the "publish web site" function in Visual Studio, all code-behind files are compiled to DLLs (in the bin folder), and the ASPX file are changed to include a reference to the corresponding DLL (in the <#Page > directive).
And regarding the "dll viewer": have a look at .NET Reflector.

MSBuild error while compiling ASP.NET website

I get the following error when I try to compile an asp.net site using a custom build script.
error ASPCONFIG: 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.
Although the description is in detail I do not understand what it means exactly. I have not configured IIS to host this website and I don't think I will be able to as I am running Vista Home Basic version. So the website cannot be built using custom scripts?Please reply as I want to test this feature.
I had this SAME EXACT problem and finally discovered a rogue Web.config was placed in my obj folder ... do yourself a favor and do a search in all the sub-directories for a web.config file. I deleted it and all was back to normal.
The rogue web.config file in the obj folder is most likely to be caused when you do a Publish Web Site. So just clean it up after you've done the publish.
if this happens after the virtual-directory is already created do the following:
right-click on web.config
properties
Build Action: Content
Copy to Output directory: Do not copy
if transformed (apply to all configurations)
properties
Build Action: None
Copy to Output directory: Do not copy
It is likely that your web.config file is placed in a directory that is not the root of the application. On most versions of IIS, you can convert any folder on your web site to an application root:
Open IIS and navigate to the appropriate folder
Right-click on the folder, select properties
Under Application Settings, and beside Application name, click Create
Apply and close
If this does not fix your problem, there may be another configuration error, either with IIS or your application.
In IIS, go to the folder that the app runs under, right click it, go to properties.
On the Directory tab, look for "Application settings". Click the create button.

Resources