Pages
Thursday, March 21, 2013
Find Currently Running Query- SQL SERVER
This script gives the list of sql queries running currently on SQL SERVER
SELECT sqltext.TEXT,
req.session_id,
req.status,
req.command,
req.cpu_time,
req.total_elapsed_time
FROM sys.dm_exec_requests req
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext
Wednesday, May 30, 2012
Visual Studio Shortcuts
Navigation
Ctrl + ] Moves the cursor to the matching Closing or Opening braceCtrl + hyphen Moves cursor to its previous position
Shift + F7 Switch between the Design View and Source View
Ctrl + Tab Displays the all open files in VS
Ctrl + Shift + F Find
F3 Search Again or continue search
Editing
Ctrl + k + c Comment a selected line or all selected lines of code
Ctrl + k + u Uncomment a selected line or all selected lines of code
Ctrl + x, Ctrl + c, Ctrl + v Cut, Copy, Paste
Code Related
Ctrl +SpaceBar Complete word if exist
Tab (Twice) Inserts Code snippet, eg type while and press Tab twice, or type prop and press Tab twice
Ctrl + Period (.) Shows SmartTag menu
F5 Start or run the application
F6 or Ctrl + Shift + B Build the solution Insert or remove breakpoint
F9 Insert or remove breakpoint
Ctrl + S Save
Ctrl + Alt + L Open Solution Explorer
Tuesday, April 17, 2012
Elmah Error Loging Module and Handler for Asp.net
Introduction
ELMAH is an open source project used to add error logging capabilities to an ASP.NET Web application. ELMAH essentially provides a means for logging and reporting unhandled exceptions in applications. I came across this very nifty tool while working with the MASS LEG team to create the Legislative Automated Workflow System (LAWS) application for the Massachusetts Legislature. We used ELMAH to uncover issues in the application that were producing unhandled and non-descriptive exceptions. Using ELMAH, the dev team was able to use the stack trace of the exception to pinpoint and fix the problem. The following provides a brief description of how to set up ELMAH and enable & configure its error logging.
Link for tutorial:
Integrating ElMAH in asp.net is preety straight forward:
1. Download ELMAH and add the Elmah.dll assembly to your web application,
2. Register ELMAH's HTTP Modules and Handler in Web.config,
3. Specify ELMAH's configuration options, and
4. Create the error log source infrastructure, if needed.
Follow instruction in tutorial, Your Final web config may look lik this:
After you change your web.Config add reference of elmah.dll to your Bin directory and create the table ELMAH_Error in sqlserver
You can execute the sqlserver.sql file in order to create table and store procedures.. and its done :)
you can see the logs by adding elmah.axd in root directory like
www.example.com/elmah.axd or localhost/something/elmah.axd
good luck
Tuesday, March 27, 2012
Vanity Url using Url Rewriting in asp.net 4.0
Url rewriting can be accomplish via two methods:
let us discuss using HTTP handler:
Since SEO comes into consideration it becomes the part of web development. These days every website being developed should be optimized to some extent so it could get crawled by Search Engines.Its advisable that you should take care of your URL’s rather than showing them in a raw format make them readable by user as well SEO friendly.
URL is the important part that search engines want to take a look before they crawl the pages of your website. There are enormous open source libraries and ISAPI filter available that provides support to help you rewriting your URLs. The SEO and url rewriting is now taken into account and is introduced a supported extension for IIS 7.0/7.5 by providing URLRewriterExtension. But here we’re going to discuss how you can rewrite you URL in your Asp.net website with just 3 steps.
1. Create a Route path entry in RouteCollection
First of all add below code your to you Global.asax file. you can add as many route as you want to the RouteCollection object.

2. Create a class specific to the particular section that implements the IRouteHandler interface
to handle the incoming Route and receiving the data from the URL

3. Finally get into the Asp.net web form and process the request
sources:
http://msdn.microsoft.com/en-us/library/ms972974
http://somenewkid.blogspot.com/2006/05/charlie-has-cool-urls-part-1.html
Download Source Code
1.HTTP module
2HTTP handlerlet us discuss using HTTP handler:
Since SEO comes into consideration it becomes the part of web development. These days every website being developed should be optimized to some extent so it could get crawled by Search Engines.Its advisable that you should take care of your URL’s rather than showing them in a raw format make them readable by user as well SEO friendly.
URL is the important part that search engines want to take a look before they crawl the pages of your website. There are enormous open source libraries and ISAPI filter available that provides support to help you rewriting your URLs. The SEO and url rewriting is now taken into account and is introduced a supported extension for IIS 7.0/7.5 by providing URLRewriterExtension. But here we’re going to discuss how you can rewrite you URL in your Asp.net website with just 3 steps.
1. Create a Route path entry in RouteCollection
First of all add below code your to you Global.asax file. you can add as many route as you want to the RouteCollection object.
2. Create a class specific to the particular section that implements the IRouteHandler interface
to handle the incoming Route and receiving the data from the URL
3. Finally get into the Asp.net web form and process the request
span style="font-family: 'Courier New';">protected void Page_Load(object sender, EventArgs e)
{
int catid = Convert.ToInt32(HttpContext.Current.Items["catid"]);
var product = awe.Products.Where(item => item.ProductSubcategoryID == catid); GridView1.DataSource = product;
GridView1.DataBind();
}
{
int catid = Convert.ToInt32(HttpContext.Current.Items["catid"]);
var product = awe.Products.Where(item => item.ProductSubcategoryID == catid); GridView1.DataSource = product;
GridView1.DataBind();
}
sources:
http://msdn.microsoft.com/en-us/library/ms972974
http://somenewkid.blogspot.com/2006/05/charlie-has-cool-urls-part-1.html
Download Source Code
Tuesday, January 31, 2012
Asp.net development server failed to start listening on port xxxx.
I got the message:
Asp.net development server failed to start listening on port xxxx.
Error Message: only one usage of each socket address is normally permitted .
Search on net, people all think that if the port is not available, just change the port for the web development server and it will work. Based on this theory, I changed the port number of the ASP.NET web development server, and it worked for me. I typed the steps here…
Error Message: only one usage of each socket address is normally permitted .
Search on net, people all think that if the port is not available, just change the port for the web development server and it will work. Based on this theory, I changed the port number of the ASP.NET web development server, and it worked for me. I typed the steps here…
Go to the Solution Explorer in Visual Studio, click on the web site application, hit ‘F4′ key to bring up the application’s property window. In this property window, set ‘Use Dynamic Port’ to ‘False’, and you will be able to set the Port number to a number other than the previous port number.
See this official MSDN document on how to change the port number for the ASP.NET development server:
http://msdn.microsoft.com/en-us/library/ms178109(VS.80).aspx
http://msdn.microsoft.com/en-us/library/ms178109(VS.80).aspx
Subscribe to:
Posts (Atom)