ASP.NET Interview questions and answers for building application

What are the 2 build options for an ASP.NET web application?
1. Debug
2. Release

What are the 3 levels at which we can have a configuration file for an ASP.NET web application?
1. At the web server level : The Machine.config file located in the Windows\Microsoft.NET\Framework\version\config directory. This sets the base configuration for all .NET assemblies running on the server.
2. At the application or web site level : The Web.config file located in the IIS root directory.This sets the base configuration for all Web applications and overrides settings in Machine.config.
3. In the sub directory of an application root folder : These settings override the settings in the root folder's web.config file.

What happens when you make changes to an application’s Web.config file?
When you make changes to an application’s Web.config file, IIS automatically restarts the application and applies the changes. This has the side effect of resetting current Application or Session state variables, which can adversely affect users.

What happens when you access the Web.config file from a browser?
For security reasons, you can’t access the Web.config file from a browser. If a user requests the Web.config file from your Web site, he or she will receive an "This type of page is not served" error message.

What happens when you access the Global.asax file from a browser?
For security reasons, you can’t access the Global.asax file from a browser. If a user requests the Global.asax file from your Web site, he or she will receive an "This type of page is not served" error message.

What are the steps to follow to host a web application on a web server?
1. Use IIS to set up a virtual folder for the application.
2. Copy the Web application to the virtual directory.
3. Add any shared .NET components to the server’s global assembly cache (GAC).
4. Set the security permissions on the server to allow the application to access required resources.

What are the 2 components that should be installed on a web server where, the ASP.NET web application runs?
ASP.NET Web applications run under IIS, so both IIS and the Microsoft .NET Framework must be installed on the server before that server can host Web applications.

What is the purpose of default start page in IIS?
A default page enables IIS to display a page if the user does not specify one in his or her request. For example, a user might make a request using only your domain name, such as
http://www.cinterviews.blogspot.com/. If a default page is enabled, IIS will respond with http://www.cinterviews.blogspot.com/default.aspx.

Don’t confuse IIS default pages with the Web Forms application start page in Visual Studio .NET. Visual Studio .NET requires that you set a start page for each project so that the development environment knows which page to display first during debugging. This setting has no effect on the IIS default page settings.

How do you copy the COM component to the server and register?
COM components generally provide a setup program to install or remove them from the system. If the component doesn’t provide a setup program, you can copy it to the server and register it using the MFC RegSvr32.exe utility, as shown below:
RegSvr32 MyComname.dll

What is GAC?
GAC stands for Global Assembly Cache. The global assembly cache (GAC) is a special subfolder within the Windows folder that stores the shared .NET components.

What is the difference between weak-named .NET components and strong-named .NET components?
This difference is how the names are stored within the assembly. Weak names are not guaranteed to be unique and thus cannot be shared without potentially causing conflicts. Strong names are digitally signed and provide a public key that ensures there are no conflicts. Furthermore, .NET components with strong names can’t call unmanaged code (such as COM components) and thus avoid potential conflicts with dependencies.

Weak-named .NET components must be individually copied to the /bin directories of the Web applications where they are used. Strong-named .NET components can be copied into the server’s GAC

What is the account under which the ASP.NET worker process run?
By default, the ASP.NET worker process runs using the ASPNET account, which is created when you install the .NET Framework. This account has limited privileges, which can cause permission-denied errors if your application writes files or tries to read files outside the current Web application’s boundaries.

What are the 3 ways in which you can modify the additional permissions required by your application.?
1. Grant the ASPNET user access to the required files. To use this option, the server must be using the Windows NT file system (NTFS).
2. Change the group the ASPNET user belongs to.
3. Use impersonation to run the process as another user.

Why is it not a good idea to add ASPNET user to the Administrators group?
Adding the ASPNET user to the Administrators group gives your Web application full privileges on the server; however, it also poses a potential security risk because outside users might be able to manipulate your application to hack your server.

How do you impersonate the ASP.NET worker process?
To use impersonation to run the ASP.NET worker process as a user other than ASPNET, set the identity element’s impersonation attribute in the application’s Web.config file.

No comments: