Archive | Tips RSS feed for this section

ASP.NET ViewState Security

ASP.NET ViewState data is stored in a single Base64-encoded string  such as  this:
id=”__VIEWSTATE” value=”dDw3NDg2NdTI5MDg7Ozr4=”/>
Since this value is not formatted in clear text, developers sometimes assume that their ViewState data is encrypted which is most certainly not the case. This data string can be reverse-engineered this and then viewed. This is an obvious security issue [...]

Read more

Using Custom Data Types in ASP.NET Profiles

ASP.NET Profile can also accept custom data types and they are relatively easy to implement
The first step is to create a class which wraps the information you require. In the class, you may use public member variables, but the preferred choice is full-fledged property procedures which will allow the  class to support data binding or other complex logic.
For [...]

Read more

Getting Started Using ASP.NET Profiles

ASP.NET Profiles are a very useful tool for  persisting user data. Most other methods of state management do not easily persist the data across user visits, but Profiles plug seamlessly into the ASP.NET Membership database to provide a convenient persistent store.
Defining Profile Properties
The first step to using Profiles is to defining them in the web.config file.  This is [...]

Read more

Run External Applications From ASP.NET

To run an external application from your ASP.NET web application use the System.Diagnostics.Process.Start method for calling the  application.
The first step for  running an external application from an ASP.NET app is to create a ProcessStartInfo object, and then pass  the name of the application to run as well as  command-line parameters it might require. In [...]

Read more

Add Custom Application Settings to web.config

ASP.NET provides for adding and then accessing configuration info specific to your app to the web.config file by using the <appSettings> element. Application configuration information is added by adding an child element to each parameter. Set the key attribute to the configuration parameter name, and then set the value attribute to [...]

Read more

Using RegisterStartupScript in ASP.NET

The RegisterStartupScript method is similar to the RegisterClientScriptBlock method. The major difference is that the RegisterStartupScript puts the script at the foot of the ASP.NET page as opposed to the top. The RegisterStartupScript method uses the same constructors as the RegisterClientScriptBlock method:

RegisterStartupScript (type, key, script)
RegisterStartupScript (type, key, script, script tag specification)

So [...]

Read more

Using RegisterClientScriptInclude in ASP.NET

The final method for registering Javascript in an ASP.NET page is the RegisterClientScriptInclude method. Most developers place JavaScript inside a .js file, which is considered best practice because it makes it simple to make global JavaScript changes to the app and .js pages are cached. You can register the script [...]

Read more

Using RegisterClientScriptBlock in ASP.NET

The RegisterClientScriptBlock method enables you to put a JavaScript function at the top of a page. Thus, the script is in place for the startup of the page in the browser. Its use is illustrated
in the below listing.

<%@ Page Language=”C#” %>
<script runat=”server”>
protected void Page_Load(object sender, EventArgs e)
{
string customScript = @”function myalert() { alert(’ASP.NET 101’); [...]

Read more

50 Tips to Boost ASP.NET Performance – Part II

Continuing from ASP.NET Performance Tips Part 1 we now conclude with Performance Tips 26-50.
26. Batched Queries:
Queries can be used in a batch and thus network traffic can be reduced: Here is an example:
“Select EmpNo, EmpName, EmpAddress from Employee”;
“Select DepNo, DeptName From Department”;
From the above two queries it seems that there will be database hit twice [...]

Read more

50 Tips to Boost ASP.NET Performance – Part I

When we are looking to optimize the performance of  web applications we should keep in mind about Memory Load, Processor Load and Network Bandwidth. Here are 50  best practices to improve the performance and scalability of ASP.NET applications.
1. Page.IsPostBack Property
Keep code which only needs to be loaded once inside an IsPostBack block.
if(!IsPostBack)
{
BindDropDownList();
LoadDynamicControls();
}
As a result there will be [...]

Read more