Showing posts with label Asp.Net. Show all posts
Showing posts with label Asp.Net. Show all posts

Thursday 30 June 2011

ASP.Net faq 2

Question:

Is it possible to share a cache object across servers in a cluster?

Answer:
The Cache object is restricted to being used only within an application running on a single machine. Microsoft concluded that the performance hit to share the objects cross-process would be too great to share it across multiple machines in a cluster (because -- unlike session state -- there are no logical synchronization boundaries to lock across).

Question:
Can session variables be accessed from code-behind?

Answer:
Yes. You can access the "Session" dictionary within a code-behind file just like you would if you were accessing it from within an line .aspx file.

For example: Session("Name") = "Scott"

Question:
What is being passed back and forth in the _ViewState form control?

Answer:
The __VIEWSTATE hidden field is used to transfer the differences in controls from what is declared in the page -- and the values they contain at the end of a request immediately prior to rendering. We can then use this information to re-construct the server controls to match that last rendered state during "postbacks" to a page.

The information within the __VIEWSTATE field is not really encrypted -- although the values are definitely "cyptic" to read (mainly because server controls try to store information in as compact a format as possible -- and because our serializer performs some limited compression).

You can see how much viewstate each control is saving by enabling tracing for the page. For example, by adding a trace attribute to the page directive:



This will cause a table to be output at the bottom of the page. This won't show the exact values stored in viewstate -- but will give you a rough estimate of the size of each server control value.

Note that you can disable the viewstate feature -- either for the entire page or on specific server controls. This is done at the page level by setting the following page directive:


or on an individual server control by setting a "maintainstate" attribute:


Question:
How do I setup web farm session state to use SQL Server?

Answer:
Run the ASP.NET Session State SQL Script to create the appropriate tables within a SQL Server database. Then modify your application's config.web file to point to this database. ASP.NET will then, under the covers, handle serializing your state from the Session intrinsic to/from the database.

Question:
What new ways are there to handle session state in a web cluster?

Answer:
There are two new methods of handling session state in a web cluster.

The first method is to designate one server as a "state server" by enabling the state service on it. This server can then be the central store of state information for the entire cluster.

Another option is to persist the state information directly to a SQL Server database. This not only gives you a shared, central store for state information but also allows you to retain state information in case of a failure or server reboot.

Question:
How well does the ASPState perform when stored in SQL Server?

Answer:
The target performance for the full release of ASP.Net will be 75-80% of the performance seen by using in-process state management.

Question:
Is there a way to directly query session data if a SQL Server StateStore is being used?

Answer:
The session data is encrypted but the creation date, expiration date,

session id, and timeout are all directly available.

Question:
Is it ok to save a dataset in Page ViewState?

Answer:
Scott Guthrie from Microsoft recommends that you avoid putting a DataSet into Page ViewState. The downside with this is that doing so can drastically increase the size of ViewState that is posted back and forth between round-trips. This can end up making a big performance difference when connecting to the application

over slow network connections (since you end up having to transmit a lot more data each way).

Instead, if you need to save the DataSet across requests, I'd recommend storing it in Session state. ASP.NET now supports web farm session state -- meaning you will no longer need to worry about being tied down to a single machine in this scenario.

Question:
Do web services support session variables and/or cookies?

Answer:
From Scott Swigart @ 3 Leaf Solutions, LLC:

It appears that in Beta 2, a web service client will not store cookies by

default (which means that Web Services that use sessions won't work). If

you want the client to support cookies, then you have to do the following:

using System.Net

wsAdv.Stateful s = new wsAdv.Stateful();

s.CookieContainer = new CookieContainer();

s.DoSomething();



Question:
Will I be able to use Output Caching and Web Farm Session State on Windows Standard edition?

Answer:
Yes. Output Caching and Web Farm Session state will be ASP.NET features that work on Windows Window Server Standard, Windows Advanced Server and Windows DataCenter Server editions.

What is the .NET Framework?
The .NET Framework is an environment for building, deploying, and running Web Services and other applications. It consists of three main parts: the Common Language Runtime, the Framework classes, and ASP.NET.

What kind of applications we can build using the .NET Framework?
The .NET Framework enables you to create great Web applications. However, it can also help you build the same applications you build today. If you write any Windows software (using ATL/COM, MFC, Microsoft(r) Visual Basic(r), or even standard Microsoft(r) Win32(r)), .NET offers many advantages to the way you currently build applications. Of course, if you do develop Web sites, then the .NET Framework has a lot to interest you-starting with ASP.NET.

How is ASP.NET different than ASP 3.0?
ASP.NET is a completely new ASP. It was written entirely from the ground up (homage to Scott Guthrie and Mark Anders for their ingenious idea) in C# (pronounced 'see sharp'). ASP.NET makes use of compilable programming languages, such as Visual Basic.Net, C#, even COBOL! (making it truely language-neutral), to write Web Applications. The applications are compiled on the server, and pages are served in HTML for the specific browser that has issued the request

What do I need to run ASP.NET?
To run ASP.NET, you must have the .NET Framework SDK. This beta software should only be installed on non-production test machines. The SDK will run on Windows(r) 2000 and Windows NT(r) 4.0 (including the NTOP for ASP.NET support), Windows 98, or Windows ME. Internet Explorer 5.5 and Data Access Components 2.6 are required.

Do I need to Visual Studio.Net in develop ASP.NET applications?
The command line compilers for VB, C# and JScript will ship with ASP.NET in addition to VS.Net. This means that you don't have to purchase/install VS.Net in order to write components with ASP.NET. You can simply install the "SDK" version of ASP.NET that will be available publicly on the Microsoft.com website and go from there. ASP.NET and the .NET Frameworks will not cost money. You will be able to download them, install them, and use them on both development and deployment servers for free

Is ASP.NET cross-browser compatible?
ASP.NET will provide multiple types of HTML depending on the browser. 'UpLevel' browsers (IE4.0+) will get HTML4.0 and Client-Side JavaScript 1.0. All other browsers ('DownLevel') will get HTML3.2 and no JavaScript. That is as of Beta 1

What platform(s) will ASP.NET run on?
Once released, you will be able to run ASP.NET on either IIS5 or IIS4 (we will not require a new version of IIS to install it). Because we run side-by-side with ASP (meaning both can run concurrently on the same box -- so your existing apps won't break at all), there shouldn't be any real adoption blockers to installing it.

You can use VS6 to edit ASP.NET Applications. Or you can use notepad. Or you can use VS7 (which has WYSIWYG Designers and Debuggers for VB, C# and C++ that target ASP.NET)

Different Errors at ASP.NET :
Welcome to the "unofficial" ASP.NET Frequently Asked Questions (FAQ) web page. These FAQs are from the Microsoft ASP.NET Newsgroup and are compiled by Carl Prothman, a Microsoft ASP.NET MVP.

Do you know of an ASP.NET FAQ which is not listed here? If so, please email to Carl Prothman and he will add it to this FAQ web page.

Asp.Net faq 1


1.1 Why are Server control tags shown in the browser instead of the controls it represents?
This is because the server control tags were not converted into their respecting HTML element tags by ASP.Net. This happens when ASP.Net is not properly registered with IIS.

.Net framework provides an Administration utility that manages the installation and uninstallation of multiple versions of ASP.NET on a single machine. You can find the file in C:\WINNT\Microsoft.NET\Framework\v**\aspnet_regiis.exe

use the command: aspnet_regiis.exe -u ---> to uninstall current asp.net version.

use the command: aspnet_regiis.exe -i ---> to install current asp.net version.

1.2 How To Repair ASP.Net IIS Mapping After You Remove and Reinstall IIS?
To reassociate aspx file extensions with ASP.Net runtime, you'll have to run the utlity aspnet_regiis.exe -i

For more information refer to Microsoft Knowledge Base Article - 306005

1.3 Why do I get "HTTP 500" error (or "(DLL) initialization routine failed") in my browser?
This is because if you have the /3GB boot switch enabled, the ASP.NET worker process (Aspnet_wp.exe) does not start. For more information see Microsoft Knowledge Base Article - 320353

To create and set the "ASPNETENABLE3GB" environment variable as mentioned in the above article, right click MyComputer ->Properties->Advanced > Environment Variables > System variables > New.

Add the variable name in the top text box and the value in the lower textbox.

1.4 I have recently move my Web application from Windows 2k to Windows Server 2003. All works fine in Windows 2K but i am not able to view pages using Windows Server 2003?

You have to enable the ASP.NET in the Web Server Extensions list

From Start -> Settings -> Control Panel -> Administrative Tools -> double click IIS Manager.

Go to the Web Service Extensions tab, click Active Server Pages, then press the "Allow" button on the left.



1.5 What are the Best practices for side-by-side execution of Framework 1.0 and 1.1?

In ASP.NET, applications are said to be running side by side when they are installed on the same computer, but use different versions of the .NET Framework. The following article at www.asp.net details the practices that are recommended ASP.NET Side-by-Side Execution of .NET Framework 1.0 and 1.1

1.6 Can I have VS.NET and the Visual Studio 6.0 installed on the same machine?

Yes! VS.Net works with the .Net framework, while VS6.0 works with MFC or the Windows API directly, for the most part. They can be installed and run on the same machine without any considerations.

1.7 How should I check whether IIS is installed or not?

To verify if IIS is installed, go to your 'Add or Remove Programs' utility in the Control panel and click on the 'Add/Remove Windows Components' in the side menu.

On XP Pro and below, you should see an item called "Internet Information Services (IIS)". If this is checked, IIS should be installed.

On Win2K3, you'll see "Application Server". If this is checked, select it and then click 'Details'. Another form should open which will contain "Internet Information Services (IIS)". If it is checked, IIS should be installed.

1.8 In Visual Studio .NET, how do I create a new ASP.NET application for an existing ASP.NET project?

First create an IIS application using the IIS MMC. Then in Visual Studio .NET, use the "New Project In Existing Folder" project template (at the end of the template list). It will first ask you for the project name (use the same one you created for the IIS application). Click OK button. Then enter in physical folder location.

1.9 Why do I get the error message "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."?

By default, ASP.NET runs its worker process (Aspnet_wp.exe) with a weak account (the local machine account, which is named ASPNET) to provide a more secure environment. On a domain controller or on a backup domain controller, all user accounts are domain accounts and are not local machine accounts. Therefore, Aspnet_wp.exe fails to start because it cannot find a local account named "localmachinename\ASPNET". To provide a valid user account on the domain controller, you must specify an explicit account in the section of the Machine.config file, or you must use the SYSTEM account. For more details : FIX: ASP.NET Does Not Work with the Default ASPNET Account on a Domain Controller

1.10 In Visual Studio .NET, how do I create a new ASP.NET application which does not have a physical path under wwwroot?
You must first create an IIS application using the IIS MMC. Then in Visual Studio .NET, create a new ASP.NET application and give it the same name you used for the IIS application

1.11 Why do I get the "Unable to find script libruary 'WebUIValidation.js'" error ?

When you install the .Net framework on your web server, it installs some script files (including the above) under the root folder (usually "C:\inetput\wwwroot" if you do a default installation) . You can then find the above file at "C:\Inetpub\wwwroot\aspnet_client\system_web\1_1_4322", for example.

The above problem could happen if you reconfigured your web root directory to be a different one after you installed ASP.Net in your web server. If that is the case, then run 'aspnet_regiis -c' (utility is under %windir%\Microsoft.NET\Framework\v1.1.4322, for example) or copy over manually the above script files into a similar sub-directory below your current web root directory. Also, if you look at the error message in detail, you will notice where the file is supposed to be.

1.12 After installing .NET Framework SP1 the client side validations, or rather validator controls are not working?

The problem seems to be in the javascript file WebValidationUi.js in aspnet_client folder.The changes in that file prevent a page to be submitted. That could be the reason your javascript validations are not working. As a workaround, just copy the old WebValidateionUi.js over the new one.

1.13 How to Configure the ASP.NET Version to use for Each Application(developed using 1.0 or 1.1)?

To configure WebApp1 to use ASP.NET 1.0, follow these steps:

1. Click Start, and then click Run.

2. In the Open text box, type cmd, and then click OK.

3. At the command prompt, locate the following directory: WindowsDirectory\Microsoft.NET\Framework\v1.0.3705\

4. At the command prompt, type one of the following commands:

o To Install ASP.NET 1.0 recursively

aspnet_regiis -s W3SVC/1/ROOT/WebApp1

o To Install ASP.NET 1.0 non-recursively

aspnet_regiis -sn W3SVC/1/ROOT/WebApp1

To configure WebApp2 to use ASP.NET 1.1, follow these steps:

1. Click Start, and then click Run.

2. In the Open text box, type cmd, and then click OK.

3. At the command prompt, locate the following directory: WindowsDirectory\Microsoft.NET\Framework\v1.1.4322\

4. At the command prompt, type one of the following commands:

o To Install ASP.NET 1.1 recursively

aspnet_regiis -s W3SVC/1/ROOT/WebApp2

o To Install ASP.NET 1.1 non-recursively

aspnet_regiis -sn W3SVC/1/ROOT/WebApp2
1.14 How to Configure Different Versions of an ASP.NET Application Running on the Same Web Server?
Here is an exerpt from the KB article: KB 816782

Find the ASP.NET Version Used for the Application View the script map for an ASP.NET application to determine the version of ASP.NET that the application uses. To view the script map for an ASP.NET application, follow these steps:

1. Click Start, point to Programs, and then click Control Panel.

2. Double-click Administrative Tools, and then double-click Internet Information Services (IIS).

3. Expand local computer, expand Web Site, and then expand Default Web Site.

4. Locate the folder that contains the ASP.NET application.

5. Right-click the folder that contains the ASP.NET application, and then click Properties.

6. Click the Directory tab, and then click Configuration. The Application Configuration dialog box opens.

7. Click the Mappings tab, and then select an ASP.NET application extension, such as .asmx or .aspx. The Executable Path column of the dialog box lists the path to the ASP.NET ISAPI version that the application uses. By default, the ASP.NET ISAPI is installed in %WindowsDirectory%\Microsoft.NET\Framework\%versionNumber%. The version number in the path indicates the version number of the ASP.NET ISAPI that the application uses. The ASP.NET ISAPI version determines the version of the runtime that the application uses.



Use Aspnet_regiis.exe to Update the Script Map

To make it easier to reconfigure the script map for an ASP.NET application, each installation of the .NET Framework is associated with a version of the ASP.NET IIS Registration tool (Aspnet_regiis.exe). You can use this tool to remap an ASP.NET application to the ASP.NET ISAPI version associated with the tool.

Note Because Aspnet_regiis.exe is linked to a specific version of the .NET Framework, you must use the appropriate version of Aspnet_regiis.exe to reconfigure the script map for an ASP.NET application. Aspnet_regiis.exe only reconfigures the script map of an ASP.NET application to the ASP.NET ISAPI version associated with the tool



Configure ASP.NET 1.0 for the Application

When ASP.NET 1.1 is configured on the root Web site, follow these steps to configure ASP.NET 1.0 for an application:

1. Click Start, and then click Run. In the Open text box, type cmd, and then click OK.

2. At the command prompt, locate the following directory path:

%WindowsDirectory%\Microsoft.NET\Framework\v1.0.3705\

3. Type the following command to configure the ASP.NET 1.0 application in IIS:



aspnet_regiis -s w3svc/1/root/ApplicationName
To remove ASP.NET 1.0 from this application, repeat steps 1and 2, and then type the following command:
aspnet_regiis -k w3svc/1/root/ApplicationName

Configure ASP.NET 1.1 for the Application When ASP.NET 1.0 is configured on the root Web site, follow these steps to configure ASP.NET 1.1 to run an application:

1. Click Start, and then click Run. In the Open text box, type cmd, and then click OK.

2. At the command prompt, locate the following directory path:

%WindowsDirectory%\Microsoft.NET\Framework\v1.1.4322

3. If ASP.NET 1.1 is not already registered, type the following command to register it: aspnet_regiis -ir Note The -ir option registers ASP.NET 1.1 without updating the scripts in IIS.

4. Type the following to configure the ASP.NET 1.1 application in IIS:
aspnet_regiis -s w3svc/1/root/ApplicationName
To remove ASP.NET 1.1 from this application, repeat steps 1 and 2, and then type the following command:
aspnet_regiis -k w3svc/1/root/ApplicationName

1.15 Why do I get error message "Internet Explorer cannot download MyPage.aspx from MyWebSite.com ..."?

This happens for example, whe you try to export data to excel from a datagrid.

The problem occurs if the server is using Secure Sockets Layer (SSL) and has added one or both of the following HTTP headers to the response message:
Pragma: no-cache

Cache-control: no-cache,max-age=0,must-revalidate

For more details refer PRB: Internet Explorer Is Unable to Open Office Documents from an SSL Web Site

1.16 Why do I get error message "Unable to start debugging on the web server. The server does not support debugging of ASP.NET or ATL Server applications. ..."?

You would get this error if the application mappings for ASP.NET file name extensions (such as .aspx) are not configured correctly in Microsoft Internet Information Services (IIS).

To resolve this go to C:\Windows Directory\Microsoft.Net\Framework\Version and type aspnet_regiis -i to configure the required application mappings correctly