Obscured URL in ASP.Net Webforms - asp.net

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.

Related

From what parts does the built Asp web forms application consists?

Can't google with a success an info about: from what parts does the built Asp web forms application consists? In a Debug folder I see only dlls, but as far as I understand the aspx pages and a web.config file should exist. Any links?
The BIN folder contains the compiled code behind. The ASPX pages and web.config stay in the same place, the root directory of your application.
Further reading:
ASP.NET Web Project Folder Structure
How to: Publish Web Application Projects
Asp applications, unlike windows forms applications need to be published first.
Right click on your project and click publish. From there pick file system option and publish to wherever you want on your computer.
Those files are the ones you upload to ftp server.

Where does IIS look for files

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.

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

Do I need a web config file to run an asp.net hello world on IIS 7?

I have uploaded a simple hello world on my IIS server 7 (shared hosting). It doesn't work. Is it necessary to add a web config and what's the minimum in that case ?
Thanks.
Error says:
Server Application Unavailable
The web application you are attempting
to access on this web server is
currently unavailable. Please hit the
"Refresh" button in your web browser
to retry your request.
Here's the script, very basic :)
<%# Page Language="VB" %>
<html>
<head>
<title>ASP.NET Hello World</title>
</head>
<body bgcolor="#FFFFFF">
<p><%= "Hello World!" %></p>
</body>
</html>
A individual, site-specific web.config is not required to be present in order to get a basic "Hello World" site up and running in IIS7, however, it's rather unusual not to have one.
IIS7, unlike previous versions, effectively has the ASP.NET worker process component "built-in". This allows web.config files to specify configuration of not only your ASP.NET site itself, but also how the IIS server hosting your site should be configured (i.e. you can specify (for example) the default document type in an ASP.NET web.config file).
If you don't specify an individual web.config for your ASP.NET site, the IIS7 server will use the "default" web.config, which is usually located in your "windows" folder within the system-wide configuration of the .NET framework itself.
This article:
Working With Configuration Files in IIS 7
from the MSDN library states:
Configuration Files
Configuration exists in a physical
directory in either server-level
configuration files or in Web.config
files. Every configuration file maps
to a specific site, application, or
virtual directory.
Server-level configuration is stored
in the following configuration files:
Machine.config. This file is located in
%windir%\Microsoft.NET\Framework\framework_version\CONFIG.
Root Web.config for the .NET Framework. This file is located in
%windir%\Microsoft.NET\Framework\framework_version\CONFIG.
ApplicationHost.config. This file is located in
%windir%\system32\inetsrv\config.
Site, application, and virtual and
physical directory configuration can
be stored in one of the following
locations:
A server-level configuration file. When configuration for a site,
application, directory, or URL is
stored in a server-level configuration
file, you must use a location tag to
specify the site, application,
directory, or URL to which the
configuration applies.
A parent-level Web.config file. When configuration for an application,
directory, or URL is stored in a
parent-level configuration file, you
must use a location tag to specify the
child at which the configuration
applies.
The Web.config file for the site, the application, or the directory.
When you configure settings for an
application, directory, or URL, the
configuration is stored in the same
directory as the site, application, or
directory. You do not need to use
location tags.
Storing configuration settings in a
parent configuration file is helpful
when:
You want to store configuration settings in a configuration file that
is accessible by only certain users or
groups. For example, the
ApplicationHost.config file is
available only to the Administrator
account and to the members of the
Administrators group on a specific
computer, as well as to domain
administrators when a computer is part
of a domain.
You want to configure a feature at the URL-level (also known as
file-level).
Also, see the following article for further information:
The new Configuration System in IIS 7
EDIT:
Regarding the specific error message that you're getting, I've seen this before on an IIS7 server, and the problem turned out to be the Application Pool that the site was set to use wasn't "running". Going into the IIS7 admin gui and starting the Application Pool cured the problem.
I have also seen this error caused wen the relevant permissions have not been set on the folder containing your website code.
See here, here, and here for further information.
Of course, since you're testing a shared hosting environment, you probably don't have access to the web server itself, and it's difficult to know exactly what you do have access to, administration-wise, through your hosting provider, but they probably have some kind of interface to set permissions on folders/files, so I'd look there first.
Failing that, you may have to include a web.config file in your "test" site as that will allow you to set configurations within IIS7 that you may otherwise have no access to.
Failing that, you may need to speak to your web host's support team.
It should be enough to inherit from machine.config. What's the exception?
I am not sure about the shared Hosting environment. But If you try to create a web application ( try ASP.Net Empty web application template) and just use Response.write("Hello World !") . it will work without any web.config.
I tried my self and it work successfully.
Only problem is that It may ask you if you wanted to debug your application then it requires to add "compilation = true" attribute in web.config.

Working folder in ASP.NET

We have a web application written in ASP.NET 3.5. In it, we access a file in the code-behind. (Ordinary C# file access, done on the server during the page life-cycle, this has nothing to do with URLs or web browsers).
On our production systems, we specify the full path to the file in question in the web.config. We'd like to be able to include a local copy of the file in the project in version control, and then to use a relative path in the version-controlled web.config to point to it, so that a checked-out copy of the application could be run from within Visual Studio's debugger without having to do any configuration.
The problem is that when the web application is running in debug mode, its working directory is neither the project nor the solution directory. In a windows or console application, in a project's properties page I can set the working directory. But in a web application I cannot.
Any ideas on how I can manage to make this work?
To get the path of the root of the application:
//equivalent to Server.MapPath("/"); if at domain root, e.g Http://mysite.com/
string path = Server.MapPath("~");
This answer gives a rundown of a few different common Server.MapPath() uses that may also be of use to you.
In code behind: HttpContext.Current.Server.MapPath("~")
Use:
Server.MapPath("~");

Resources