Banner Ad

Monday, September 14, 2015

How to improve the performance of an ASP.Net Web page?

By Francis   Posted at   9:22 PM   Webpage No comments
Performance         
                     This is the most common question from asp.net forum to any interview. In this post I’m going to point out some of the important points that may help to improve the performance.
                      Here I used the word “improve performance” in the sense to decrease the loading time of the page. There are various reason behind. Some of them we look into from the “backend side” (Database side) and rest of them we need to take care in “front-end” ((UI) side.
For illustrative purpose, you have a ASP.Net Web site, one of the aspx page take much time to load. Also as a backend I assume that you are using SQL Server. Through out this article, we are going to see how to decrease the loading time.
Back End (DB):
Below are the points that you need to consider to fine tune the DB:
1) Try to check the Query performance, that is how much time the query will take to execute and pull the records from DB. The Use SQL Server Profiler and Execution plan for that query. So that you can come to the conclusion in which part it took much time.
2) Check in every table (who are all part of the query) Index is created properly.
3) If your query involves an complex Stored procedure, which in turn use lot of joins, then you should focus on every table. In some cases, sub-query perform better than the joins.
4) If your web page, involves paging concepts, try to move the paging concepts to SQL Server. I meant that based on the page count the SP will return the records, instead of bring the records as a whole.
Front End (UI):
1) If your page displays a lot of records, try to introduce “paging”. Say for example your page displays 1000 record in a page. Instead of pulling 1000 records as a whole, by introducing paging such that page size as 10, you need to pull 10 records only!
2) Try to choose “tabless” design, that is try to avoid “table” to design the webpage. In order to achieve this use should use “div” tag.
3) If you want to design responsive pages, try to use existing (proved) frameworks such as Bootstrap, instead of trying your own code.
4) Also if your webpage deals with lot of images or videos to display, then consider to use appropriate CDN (Content Delivery Network).
5) Use bundling and minification techniques, which reduce the server calls to load the javascript and CSS files, which in turn reduce the loading time.


Readers!! Do you thing that I have missed out anything? Let me know your thoughts in comments! Smile

Wednesday, September 9, 2015

How to publish ASP.Net Web application using Visual Studio 2015

By Francis   Posted at   6:52 PM   Visual Studio No comments

                             In this post, we are going to see a step by step procedure using the custom profile option. In other words, this post is going to explain how to publish the website in local file system.

                       The main purpose of publish dialog is provide an simplified way to take the file list which need to be publish on your website. In this article I’m going to explain how to publish a MVC web application using the “publish” dialog provided in VS 2015.

 Step 1 : Open Publish Dialog

                    You can open the publish dialog by “Right Click” on the project then select “Publish” on the floating menu.

PublishCommand

 

Step 2: Create Profile

                       As a first step, you should create a profile before publishing. This is just one kind of grouping, say for example you can create multiple profile one for Azure and one for local. So when next time you open this dialog you can see the profiles and select from them.

PublishDialog

I have selected “Custom” as a “Publish Target” and gave profile name as “LocalPublish”.

PublishProfileDialog

Step 3: Select the Connection

In this step, we need to tell where our published files are going to be. You can publish the files directly on your server also by selecting “Web Deploy” publish method or you can use FTP too.

PublishOptions

Since I’m going to publish files in local file system so I selected “File System”.

PublishInLocal

Step 4: Select Configuration and other settings

In this step, you can choose “Configuration” mode and other settings like delete files before publishing in the specific folder, precompile etc.

PublishMode

 

Step 5: Preview & Publish

You are about to complete your publishing. Click publish to start the publishing.

PublishPreview

In the output window you can see the result of the publish.

OutputWindowAck

 

Hope this post is useful who are all using the “Publish” option in Visual Studio 2015.

Happy Coding!!

Monday, September 7, 2015

How to Hosting Asp.net MVC Web Application in Local Machine?

By Francis   Posted at   2:32 PM   IIS No comments

                     In this post I’m going to discuss about how to host an ASP.Net MVC Application in your  local machine. Most of the steps to deploy a web form application and MVC applications are equivalent.

Prerequisite:

           In order to explain the steps, I assume you have a complete ASP.Net MVC Application that is ready to build with out any error.

Step 1:

Publish you MVC application in a local file path, using publish option in Visual Studio.

publishOptionInVS

For this example, I have published my application in the below path like : C:\MVCDemo

ASPNETPublishedFiles

Step 2:

Create a Virtual directory in IIS and mapped the above published file path to it.

MVCAppVirtualDirectory

If you have any doubts in creating virtual directory refer my below blog posts:

Create virtual directory on IIS using Visual Studio.

Create Virtual directory on IIS

Step 3:

You are almost done! The only thing pending is you need to browse the website, that just published. This is where most of the ASP.Net developer (especially who is a newbie to ASP.Net MVC), what they were doing : Expand the Virtual directory –> Views –> Switch to content view –> select the cshtml file –> right click on it and click “Browse”, which throws 404 Error in browser.

BrowseMVCFile

404Error

 

The above issue is common to all ASP.Net developers, who are all comes with ASP.Net  WebForm background. In order to browse the  mvc application, you need to mention the path in the form like “http://localhost/YourControllerName/YourActionMethod", which is the url routing pattern specified by default.

 

ASPNetApplication

 

Hope this helps!

Thursday, September 3, 2015

Daily Interview Questions #15 : What is the difference between the C# keywords ‘ref’ and ‘out’?

By Francis   Posted at   5:26 AM   C# Interview Questions No comments

ref

out

Parameters passed with the prefix “ref”. By using “ref” C# implements the concept called “Call by reference”. Parameters passed with the prefix “out”.
An argument passed by ref must be assigned with a value before the call. ‘out’ parameter must assigned with some value prior to the termination of the function.

Tuesday, August 18, 2015

How to Send SMS From ASP.Net Web Application?

By Francis   Posted at   7:14 PM   SMS Gateways 20 comments
Disclaimer:
            In this article I have used a Third party SMS Gateway service provider, which is I have personally used and experienced.
Introduction:
                    In my previous article I explained SMS Gateways and the various schemes available for them. This article explains how to integrate those SMS gateways into an ASP.Net web application.
What a "SMS Gateway" is?
                   A SMS Gateway allows a computer to send or receive SMS to or from a telecommunications network. This Wikipedia URL provides more detail.
Some “facts” about SMS Gateways
                  When I did some experimentation and Googling of SMS gateways some of the tutorials suggested use of “free” SMS gateways. But nothing worked for me. Latter I understood that “Nothing comes free”. Also most people asked the same question: “Is there any free SMS service is available to send SMS from my website?”. In my experience the answer is no. So my point here is, don’t waste your time searching for the free API. Instead, find a well-suited SMS Gateway provider and sign up with them.

Connect with Us