Category Archives: ASP.NET

Generate WebReferance Proxy using wsdl.exe


To generate web reference for you project use wsdl.exe and then including the generated file (.cs) into your project.

Based on the .NET framework version your wsdl.exe file will exist in corresponding path as below

In case anyone using VS 2008 (.NET v3.5) is also looking for the wsdl.exe.
I found it here:
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\wsdl.exe

Future versions C:\Program Files\Microsoft SDKs\Windows\vx.xx\bin\wsdl.exe

For v4.5.1
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\wsdl.exe

For v4.6.1
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\wsdl.exe

Using any one of below command can generate proxy class

wsdl /language:CS /n:”<NameSpaceName>” <Path of wsdl file>.wsdl

wsdl.exe /language:CS <Path of wsdl file>.wsdl

wsdl.exe <Path of wsdl file>.wsdl

Ref: https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-2.0/7h3ystb6(v=vs.80)?redirectedfrom=MSDN

About Nuget


In Visual studio to add any reference in our project we will use ‘Add Reference Dialogue’, but in last few years apart from .net assemblies, we are started incorporate lots of 3rd party libraries(.NET open source libraries) into our projects.If you manually add any .NET open source assemblies some time it takes too much effort to make it work with the project. We can avoid this manual configuration through Nuget Packages available for VS2010 and from VS2012 this feature is comes by default during installation.

Nuget is type of Open source Package management system and it is a huge repository. Using Nuget we can include required assembly in to out application. we can make use of Package Manager Console window in VS to install any external assembly that is available in Nuget.

List of HTTP response status codes


Application that we developed sometime unexpectedly show error message or some time during debugging need to identify the status of the request. To identify the type of error or response status codes very first thing will see the error code returned by the page. Based on the response status code we can narrow down the error type or identify the status of the request like Success/failure.

Basically we can group the response status code in 4 different types
1) Informational (1XX)
2) Success (2XX)
3) Redirection (3XX)
4) Client (4XX)

 

Each group have different type of status code for more you can reffer here

ASP.NET Web Configuration Tool missing in VS2013


I’m using Visual Studio 2013 and as you probably know there is no ASP.NET Web Configuration Tool but Just now i came to know about it. Still i want to access it, so first i want to know why they remove this option. While surfing on net i came to know that this is due to removal of Visual Studio Development Server  (or Cassini) from the product.

Now now let see how we will access our Web Configuration Tool
Through your VS2013 console, copy and paste below code

“C:\Program Files\IIS Express\iisexpress.exe” /path:c:\windows\Microsoft.NET\Framework\v4.0.30319\ASP.NETWebAdminFiles /vpath:”/asp.netwebadminfiles” /port:8089 /clr:4.0 /ntlm

Please wait …. don’t exit the command prompt by pressing ‘q’.

Again copy and past the url in a browser and edit ‘[Exact_Project_Path]’ part with your physical application path

http://localhost:8089/asp.netwebadminfiles/default.aspx?applicationPhysicalPath=%5BExact_Project_Path%5D\&applicationUrl=/

That all 🙂

EnableViewState=”false” of a page


When I disable ViewState for the page. It does not allow any control in the page to use ViewState even if I set ViewStateMode=”true” property of a control.
This is because I set turn page’s ViewState off, then there is no way for you to enable ViewState for specific components. This is because ViewState is serialized recursively, so when if the Page is not allowing ViewState, it will not serialize the ViewState for any of it’s child controls.

 

Regular expression validation for email


Normally if you use ‘RegularExpressionValidator’ control to validate the E-Mail, you will select ‘Internet Email address’. By default it will return ‘\w+([-+.’]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*’

Above expression will accept like ‘kethare@mydomain.co.in.info’, But in my scenario it should accept only two sub domain as ‘kethare@yahoo.co.in’

ValidationExpression=’^[-0-9a-zA-Z.+_]+@[a-zA-Z+_]+\.[a-zA-Z]{2,4}\.{0,1}[a-zA-Z]{2,4}$’

Difference between Eval() and Bind()


|<%# Eval(“”) %>                | <%# Bind(“”)%>
—-|————————————|—————————————
1   |OneWay Binding               | Bind is two-way
2   |Readonly databinging     | Read/write databinding

Normally Bind() method is used inside the Gridview or other datacontrol to extract the data back to the datasource from the child controls in the template. Normally
the Bind() used inside the EditItemTemplate and InsertItemTemplate of databound countrol.

Date Formatting


Paging

Numeric Formating using String.Format


This String.Format method accepts a format string followed by one to many variables that are to be formatted.

Paging

Managing Data Persistent With ASP.NET


 

Persistence Method Number of Users Expire Time Data Size
Application All users Until the next application restart Any Size
Cookie One user As short as desired, or for months or even years if the user doesn’t delete their cookies Small data
Form Post One user For the next request (can be reused across many requests) It store virtually any amount of data
QueryString One user or one group of users For the next request (can be reused across many requests) Simple Data
Session One user As long as the user is active, plus a timeout period (typically 20 minutes) Can store any amount of data.
Cache All users or a subset of users As long or as short as needed Any type and size of data
Context One user This request only Can hold large objects, but typically does not since it is often used for every request
ViewState One user One Web form Reasonable amount of data
Config file All users Until the configuration file is updated Can hold a lot of data; usually organized as many small strings or XML structures

For More 

%d bloggers like this: