Search This Blog

Monday, December 15, 2008

ASP.Net Coding & Performance Tips

ASP.net Tips

from http://www.codersource.net/asp_net_simple_tips.html


1.Smart navigation

Smart navigation is a little-known Internet Explorer feature that enables the individual controls on your Web forms to maintain focus between postback, as well as allows you to suppress that flicker that occurs as you load the new page.
To turn on this little-known feature, simply set the smartNavigation property of your ASPX page to True. You can also apply the property to all project pages, by adding the tag to the following location within your Web.config file:

<--configuration system.web pages smartNavigation="true"/ /system.web /configuration -->

Note that smart navigation works on only Internet Explorer 5 and above; however, ASP.NET will automatically detect this and serve up the ?smart? code only if the target browser supports it.

Also,I'd personally advise that you test it against any third-party menu controls or scripts you may have running: it is prone to falling over on particularly advanced pages.


2.Stopping Your User from Right-Clicking


Want to prevent your user from performing any of the other commands available by right-clicking on a Web page in Internet Explorer? It?s not foolproof, but this neat little HTML edit usually does the trick.

Just alter the opening tag of your HTML to the following:

BODY oncontextmenu="return false">

When the menu is requested, the oncontextmenu event runs, and we instantly cancel it using JavaScript. This is especially potent as a method for stopping the user from viewing your source, when used in conjunction with a menu-less browser window. Great stuff!

3.Creating Images Dynamically

Ask any ASP developer who has ever tried to dynamically create his own images and he?ll tell you it?s a nightmare. In fact, it?s more than a nightmare. It?s practically hell. The only true solution? Reverting to an expensive, dodgy, third-party control to do the work for you.

With ASP.NET, however, you can develop your own dynamic images with ease. Simply create an image object and use the new GDI+ features to add objects to that image, such as text, rectangles, and ellipses. After that, you can simply stream straight back down to the client.

But covering the graphics features in depth would require at least another two books, and, unfortunately, we don?t have that much room. So, I?m going to share a sample that demonstrates creating a small ?Drawing? button, alongside a little blue-and-yellow bullet point.It?s the sort of personalized graphic you?ll find on sites such as Amazon.com.

Here's the code:

Bitmap objBitmap = new Bitmap(120, 30);
Graphics objGraphics = Graphics.FromImage(objBitmap);
objGraphics.FillRectangle(new SolidBrush(Color.LightBlue), 0, 0, 120, 30);
objGraphics.FillEllipse(new SolidBrush(Color.Blue), 3, 9, 10, 10);
objGraphics.FillEllipse(new SolidBrush(Color.Yellow), 4, 10, 8, 8);
objGraphics.DrawString("Drawing", new Font("Tahoma", 8), new SolidBrush(Color.Green), 16, 8);
Response.Clear();
Response.ContentType = "image/jpeg";
objBitmap.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
objGraphics.Dispose();
objBitmap.Dispose();


You can put it inside any event you want.

4.Clear All The Textbox Values (Reset Function)

In Classic ASP, to clear all the textboxes in a form, to start over, we just had to use a simple html 'Reset' button in the form. Sometimes that works in ASP.Net;sometimes it doesn't.

Here are a couple of ways to do this, iterating through the ASP.Net TextBox controls in a form --
Just create a Reset type subroutine - in that routine, use the following code:
in C# - it would be:

Control myForm = Page.FindControl("Form1");
foreach (Control ctl in myForm.Controls)
if(ctl.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"))
((TextBox)ctl).Text = "";

This will clear EVERYTHING from the textboxes - even if you had them pre-populated with data. A VERY simple way to just reset it to the condition at Page_Load time, just do this in the Reset SubRoutine:

Server.Transfer("YourPageName.aspx")

5.Pressing Enter key

Sometimes, you will notice, that, in an ASP.Net form, depending on the circumstances, pressing the 'Enter' key to submit the form does not work.

To force this to happen for a particular button on your page, just put this in the Page_Load routine:

Page.RegisterHiddenField("__EVENTTARGET", "button1")

Then, change 'button1' to the ID of your particular button. Understand, of course, if your cursor is inside of a MultiLine textbox, the default action of the enter key is to create a new line in the textbox, so, if this basically works anywhere outside of that scenario.
6.ASP.Net Server Controls Not Showing on pages

It's possible that ASP.Net is not registered correctly on your system.Try running aspnet_regiis from the command prompt
.

Here's the default location:

C:\WINNT\Microsoft.NET\Framework\<>\aspnet_regiis.exe -i

Windows Server 2003, you must use aspnet_regiis -i -enable. This is because of the "Web Service Extensions" feature in IIS 6

7.Where To Store Database Connection

Let's say you have a database connection (or several) that you will be using over and over. Yes, you can manually copy/type it in on every ASP.Net page - BUT - an easier way is to store it in the Web.Config file (formerly config.web) and then refer to it in the code.

In Web.Config, you would add a key to the AppSettings Section:

appSettings>
add key="MyDBConnection" value="server=YourServer;uid=Username;pwd=Password;database=DBName" />


for OleDb - use Absolute Path - Not Server.MapPath:
add key="NWOleDB" value= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\data\northwind.mdb;" />

Then, in your ASP.Net application - just refer to it like this:

SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings("MyDBConnection"));


Sunday, December 14, 2008

Quick Tips For ASP.Net

Quick Tips For ASP.Net

from http://simpable.com/code/quick-tips-for-asp-net-part-one/

written by Scott Watermasysk on Thursday, February 15 2007

Just about everyone has been to a session on ASP.Net best practices, read a book or 10 on the subject, and possibly even a couple of blog posts or MSDN articles. This post is NOT one of them. It is simply a quick list of tips and suggestions for making your ASP.Net application a little better.

I jotted down the tips below over the course of the morning. It is by no means exhaustive and I hope to publish another set of tips or two shortly. If you have any other suggestions/tips, please list them below. If you are not the kind of person who likes to comment on a blog, please drop me a line at scottwater@gmail.com. I will either add them below or create another post and list them. I am also working on a set of caching tips, so if you have any of them, there will be a specific post related to caching.

Tip: Do not use the AutoPostBack attribute on the DropDownList control to simply redirect to another page.

There are probably cases when this might make sense, but for the most part it is overkill. Using the autopostback for a redirect requires extra roundtrip to the server. First the autopostback returns to the server and processes everything up to the event handling the postback. Next a Response.Redirect is issued which goes back to the client requesting the client use another page. So you end up with two separate requests + processing just to get a user to another page.

Using the onchange event of the select element, we can do this all on the client. In the sample below, I am simply redirecting to the current page with an updated querystring element. Your logic will vary, but in the case below, I am avoiding the zero index.

0) { window.location = window.location.pathname + '?t=' + this[this.selectedIndex].value;}" />

Tip: Never use the ASP.Net Label control.

Ever is a strong word, but except for some quick and dirty style hacks you should never ever use this control. Any text is rendered inside a span control which is usually unnecessary and complicates any CSS styling you may be trying to use. In most cases, you can replace the Label with a Literal and achieve the same results.

Tip: Use the ASP.Net Repeater instead of DataList, DataGrid, and DataView controls

The Repeater is the single most powerful control shipped in ASP.NET. It is versatile and lightweight. There are times (especially prototyping) when the other databound controls make sense to use, but they generate a lot of extra markup and generally complicate the page with all of their events and styling. Using the Repeater, you may write a little more code up front, but you will be rewarded in the long run.

Tip: Understand how to effectively use caching.

By now, most ASP.NET developers know about the Cache. Most examples show the virtue of caching for hours at a time. Very little data that is worth the effort to display on a web page requires caching for this long. The main reasons for caching are performance related. Memory in ASP.NET is still a very limited resource. Do not waste it by caching anything more than a couple of minutes unless it is very expensive to regenerate.

Tip: Always set a memory threshold for your AppPool.

A related tip would be to first understand the total memory available on your box: how many sites are there, is SQL running locally? Is there anything else on this box which will consistently use Memory?

In most cases, you should never set the available memory for an AppPool above 800mb's unless you can also set the 3/gb switch (then you can use about 1200mb). Allowing memory to go unchecked or set about 800mb can bring even a moderately sized site to it's knees once too much memory is used.

Tip: Use AppOffline.htm for updates

If you are making any changes to files in your bin directory, always use the AppOffline.htm file. It is very likely that while you uploading (or copy & pasting) your updates, users will see an error message. It is much better to show them one that you purposely created and can explain the situation vs. the built in ASP.NET error pages (or even your own customError page). In addition, this will help prevent the locking .dll issue that is not supposed to exist anyway.

Tip: Always check Page.IsValid in your button's EventHandler.

Just because you are using ASP.Net validation controls, do not assume the page could not be submitted with invalid data.

Also, just because you hide a control, do not assume buttons/textboxes/etc on it are not submit-able. It is perfectly fine to hide a control that a user should not access, but with very little code (or using a third party tool) users can easily make an HttpPost with any data they choose.

Tip: When redirects are permanent, use a 301 status code.

This use to be a little more manual, but with ASP.NET 2.0, it is even easier:

Response.RedirectLocation = "http://site.com/newlink.aspx";
Response.End();

Tip: To create fully qualified URLs, use the new VirtualPath class.

string relativePath = "~/somefolder/test/123.aspx"
Uri newUri = new Uri(Request.Url, VirtualPathUtility.ToAbsolute(relativePath));

Again, please add any other suggestions below. I am looking forward to reading them.

Update: It looks like there is a case for using the Label control as an html label element (for accessibility). I was unaware of this functionality and will call it out better in another tip installment. Thanks Phil and Dusty!

Friday, October 10, 2008

Regular Expressions in .Net

Hi friends,

Want to get Regular Expressions for your Custom Validator in .Net, go to the Link below.

http://regexlib.com/

Wednesday, September 24, 2008

How do I catch the RowIndex in GridView RowCommand event?

The Solution for catching it is as below

Hi,

In row command if you want to get the current row or its index, It is not directly possible. There is two way, one is on row created event on the link button(suppose, it is used for row command) save row index in link button command argument attribute.

And get the argument from row command event using e.CommandArgument

But if you want to send another value as a command argument then it creates problem. To solve this just use this code

GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);

Here link button (or any source) that cause to enter in row command event. Now you have selected row so you don’t need any index and directly access any row variable as sample code is given below
Label lblProdId = (Label)row.FindControl(”lblproductId”);

So whole code is just two line. Below I write whole code

-------------------------------------------------------------------------------
GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);

Label lblProdId = (Label)row.FindControl(”lblproductId”);

-------------------------------------------------------------------------------
Source from : http://ranafaisal.wordpress.com/2008/03/31/how-to-get-the-current-row-in-gridview-row-command-event/

Saturday, September 20, 2008

How to add a default ListItem to a DropDownList

This can be done one of 2 ways. A default ListItem can be added to a DropDownList programmatically with the following syntax after binding data to the DropDownList:


//Code here to populate DropDownList

DropDownListID.Items.Insert(0, new ListItem("Default text", "Default value")

This will add a ListItem to index 0, which will be the first ListItem.

In .NET 2.0, this can be done declaratively using the AppendDataBoundItems property. This will append all data-bound ListItems to the DropDownList, leaving those you add manually as the first selections.




Solution by : Ryan Olshan
ASPInsider | Microsoft MVP, ASP.NET
http://ryanolshan.com

Saturday, August 30, 2008

Windows Communication Foundation Architecture

Windows Communication Foundation Architecture
The following graphic illustrates the major layers of the Windows Communication Foundation (WCF) architecture.


WCF Architecture




Contracts and Descriptions

Contracts define various aspects of the message system. The data contract describes every parameter that makes up every message that a service can create or consume. The message parameters are defined by XML Schema definition language (XSD) documents, enabling any system that understands XML to process the documents. The message contract defines specific message parts using SOAP protocols, and allows finer-grained control over parts of the message, when interoperability demands such precision. The service contract specifies the actual method signatures of the service, and is distributed as an interface in one of the supported programming languages, such as Visual Basic or Visual C#.

Policies and bindings stipulate the conditions required to communicate with a service. For example, the binding must (at a minimum) specify the transport used (for example, HTTP or TCP), and an encoding. Policies include security requirements and other conditions that must be met to communicate with a service.

Service Runtime
The service runtime layer contains the behaviors that occur only during the actual operation of the service, that is, the runtime behaviors of the service. Throttling controls how many messages are processed, which can be varied if the demand for the service grows to a preset limit. An error behavior specifies what occurs when an internal error occurs on the service, for example, by controlling what information is communicated to the client. (Too much information can give a malicious user an advantage in mounting an attack.) Metadata behavior governs how and whether metadata is made available to the outside world. Instance behavior specifies how many instances of the service can be run (for example, a singleton specifies only one instance to process all messages). Transaction behavior enables the rollback of transacted operations if a failure occurs. Dispatch behavior is the control of how a message is processed by the WCF infrastructure.

Extensibility enables customization of runtime processes. For example, message inspection is the facility to inspect parts of a message, and parameter filtering enables preset actions to occur based on filters acting on message headers.

Messaging
The messaging layer is composed of channels. A channel is a component that processes a message in some way, for example, by authenticating a message. A set of channels is also known as a channel stack. Channels operate on messages and message headers. This is different from the service runtime layer, which is primarily concerned about processing the contents of message bodies.

There are two types of channels: transport channels and protocol channels.
Transport channels read and write messages from the network (or some other communication point with the outside world). Some transports use an encoder to convert messages (which are represented as XML Infosets) to and from the byte stream representation used by the network. Examples of transports are HTTP, named pipes, TCP, and MSMQ. Examples of encodings are XML and optimized binary.
Protocol channels implement message processing protocols, often by reading or writing additional headers to the message. Examples of such protocols include WS-Security and WS-Reliability.

The messaging layer illustrates the possible formats and exchange patterns of the data. WS-Security is an implementation of the WS-Security specification enabling security at the message layer. The WS-Reliable Messaging channel enables the guarantee of message delivery. The encoders present a variety of encodings that can be used to suit the needs of the message. The HTTP channel specifies that the HyperText Transport Protocol is used for message delivery. The TCP channel similarly specifies the TCP protocol. The Transaction Flow channel governs transacted message patterns. The Named Pipe channel enables interprocess communication. The MSMQ channel enables interoperation with MSMQ applications.

Hosting and Activation

In its final form, a service is a program. Like other programs, a service must be run in an executable. This is known as a self-hosted service.

Services can also be hosted, or run in an executable managed by an external agent, such as IIS or Windows Activation Service (WAS). WAS enables WCF applications to be activated automatically when deployed on a computer running WAS. Services can also be manually run as executables (.exe files). A service can also be run automatically as a Windows service. COM+ components can also be hosted as WCF services.

See Also
Concepts

What Is Windows Communication Foundation?
Fundamental Windows Communication Foundation Concepts

Monday, March 17, 2008

Service Oriented Architecture

A service-oriented architecture (SOA) is the underlying structure supporting communications between services. In this context, a service is defined as a unit of work to be performed on behalf of some computing entity, such as a human user or another program. SOA defines how two computing entities, such as programs, interact in such a way as to enable one entity to perform a unit of work on behalf of another entity. Service interactions are defined using a description language. Each interaction is self-contained and loosely coupled, so that each interaction is independent of any other interaction.

Simple Object Access Protocol (SOAP)-based Web services are becoming the most common implementation of SOA. However, there are non-Web services implementations of SOA that provide similar benefits. The protocol independence of SOA means that different consumers can communicate with the service in different ways. Ideally, there should be a management layer between the providers and consumers to ensure complete flexibility regarding implementation protocols.

Whether you realize it or not, you've probably relied upon SOA, perhaps when you made a purchase online. Let's use Land's End as an example. You look at their catalog and choose a number of items. You specify your order through one service, which communicates with an inventory service to find out if the items you've requested are available in the sizes and colors that you want. Your order and shipping details are submitted to another service which calculates your total, tells you when your order should arrive and furnishes a tracking number that, through another service, will allow you to keep track of your order's status and location en route to your door. The entire process, from the initial order to its delivery, is managed by communications between the Web services -- programs talking to other programs, all made possible by the underlying framework that SOA provides.
___________________________________________________________________

Abbreviated SOA, an application architecture in which all functions, or services, are defined using a description language and have invokable interfaces that are called to perform business processes. Each interaction is independent of each and every other interaction and the interconnect protocols of the communicating devices (i.e., the infrastructure components that determine the communication system do not affect the interfaces). Because interfaces are platform-independent, a client from any device using any operating system in any language can use the service.

XML Though built on similar principles, SOA is not the same as Web services, which indicates a collection of technologies, such as SOAP and XML. SOA is more than a set of technologies and runs independent of any specific technologies.

____________________________________________________________________

A service-oriented architecture is essentially a collection of services. These services communicate with each other. The communication can involve either simple data passing or it could involve two or more services coordinating some activity. Some means of connecting services to each other is needed. The combination of services - internal and external to an organization - makes up a service-oriented architecture.

If a service-oriented architecture is to be effective, we need a clear understanding of the term service. A service is a function that is well-defined, self-contained, and does not depend on the context or state of other services. Services are what you connect together using Web Services. A service is the endpoint of a connection. Also, a service has some type of underlying computer system that supports the connection offered.

The technology of Web Services is the most likely connection technology of service-oriented architectures. Web services essentially use XML to create a robust connection.

______________________________________________________________

http://15seconds.com/issue/031215.htm

http://www.c-sharpcorner.com/UploadFile/john_charles/
Service_Oriented_Architecture_and_Microsoft_NET01202006080616AM/
Service_Oriented_Architecture_and_Microsoft_NET.aspx

http://msdn2.microsoft.com/en-us/architecture/aa948857.aspx

http://www.devshed.com/c/a/Web-Services/Introduction-to-Service-Oriented-Architecture-SOA/


Friday, February 15, 2008

AJAX: Usable Interactivity with Remote Scripting

This article aims to give you an introduction to the foundations of remote scripting, in particular, the emerging XMLHttpRequest protocol. We'll then walk through an example application that demonstrates how to implement that protocol, while creating a usable interface.

What Is Remote Scripting?
Essentially, remote scripting allows client-side JavaScript to request data from a server without having to refresh the Web page. That's it. Everything else that goes into making a seamless Web application draws upon the established methods of manipulating the Document Object Model. This might be something as simple as creating a list of words to select from, as per Google Suggest. Or it could involve the creation of an entire interface for navigating and zooming map images, like that at map.search.ch.

However, along with the ability to create new Web experiences, remote scripting gives us the ability to make new unusable Web experiences. Remote scripting and seamless applications bring with them a host of problems from the desktop application design realm, making those same issues possible on the Web. It's your duty to ensure that your remote scripting interfaces address those issues, and give your users the best possible experience they can get.

http://www.sitepoint.com/article/remote-scripting-ajax

.Net Attributes

Takeaway: .NET's new attributes design elements are commonly misunderstood. Attributes can be used to document classes, specify runtime information, and even dictate runtime behavior.


Among the most confusing and misunderstood elements of the .NET framework are the purpose and uses of attributes. Since attributes are new to both C++ and VB developers, there’s no context for easy comparisons to familiar language elements. But the addition of attributes to the Common Language Runtime (CLR) gives developers new abilities to associate information with their classes via an annotation mechanism, which the CLR can then use to operate on the objects at runtime.

Attributes can be used to document classes at design time, specify runtime information (such as the name of an XML field to be used when serializing information from the class), and even dictate runtime behavior (such as whether the class should automatically participate in a transaction). More importantly, you can develop your own attributes that specify architectural standards and enforce their use. In this article, we’ll look at how the CLR uses standard attributes and how and why you should create your own attributes.


What is an attribute?
Many .NET developers get their first exposure to attributes when using templates provided in the Visual Studio environment. For example, when a VB developer creates a new XML Web Service, they get back sample code that defines the Web Service to the CLR using attributes like this:


<WebService(Namespace := "http://tempuri.org/")> _
Public Class Service1
Inherits System.Web.Services.WebService


The class Service1 is said to have been “decorated” with the WebService attribute, and the NameSpace variable has been assigned the value of http://tempuri.org/. The WebService and WebMethod attributes signal the compiler that these attributes should be accessible using the SOAP protocol. As you can see from this example, the purpose of .NET attributes is to signal a compiler or the runtime to generate MSIL or to operate on the MSIL generated, based on metadata representing the attribute. There are many other examples of using attributes to instruct the compiler how to generate the appropriate MSIL, including:
  • Using MarshalAsAttribute to tell the compiler how to marshal method parameters when interoperating with native code.
  • Using COMClassAttribute to mark components as COM so the Visual Basic compiler will generate code allowing a .NET component to be called from COM.
  • Using attributes to describe the resulting assembly with title, version, or description information. The version information is especially important when using signed assemblies and the Global Assembly Cache because you can force the runtime to load only particular versions of assemblies and avoid the COM DLL Hell problem.
  • Mapping class members to specific XML node types when defining XML serialization.

When compiled, attributes are saved with the metadata of the finished assembly. At runtime, the CLR or your own programs can still use any attributes used by the compiler to control code generation by using reflection to query the assembly for the values specified by an attribute. The feature that makes attributes most powerful, however, is their ability to add additional capabilities to any language hosted within the .NET runtime without making changes to the language compilers.

Adding language capabilities
Attributes are not language specific. Just as we can decorate the HelloWorld method in VB with the WebMethod attribute, there’s a similar implementation for C#:


[WebMethod]

public string HelloWorld()
{
return "Hello World";
}


Since attributes are language independent, you can define new functionality by creating attributes that inherit from the System.Attribute class. You can then apply that functionality to programs written in any language by simply decorating the appropriate classes, methods, or properties at design time.

For example, one company that I’m working with has defined its own extensions to the CLR that implement metering via performance counters and dynamically created usage statistics. The company has implemented the functionality by creating a set of attributes that can be applied at the module, class, method, event, or property level at design time. Once these attributes are applied, the compiler can include their code to implement this functionality at compile time and the CLR can use reflection to collect the information defined by the attributes at runtime. Using this mechanism allows the company to implement standard metering and usage statistics functionality across all its .NET systems.

Attributes are a good thing
The implementation I’ve discussed here is just one example of how companies are using .NET attributes to standardize operations across their development efforts. .NET Architects who take the time to examine and apply this new technology will undoubtedly find other ways to use it in the applications they design.

Wednesday, January 30, 2008

Improvements in ASP.NET 3.5

  • A new data control, ListView, for displaying data
  • A new data source control, LinqDataSource, that exposes Language Integrated Query (LINQ) to Web developers through the ASP.NET data source control architectures
  • A new tool, ASP.NET Merge Tool (Aspnet_merge.exe), for merging precompiled assemblies
  • Tight integration with IIS 7.0. ListView is a highly customizable control (using templates and styles) that also supports edit, insert, and delete operations, as well as sorting and paging functionality.
  • The paging functionality for ListView is provided by a new control called DataPager. You can use the merge tool to combine assemblies to support a range of deployment and release management scenarios.
  • The integration of ASP.NET and IIS 7.0 includes the ability to use ASP.NET services, such as authentication and caching, for any content type. It also includes the ability to develop server pipeline modules in ASP.NET managed code and supports unified configuration of modules and handlers.

What's New in the .NET Framework Version 3.5

This topic contains information about new and enhanced features in the .NET Framework version 3.5.

.NET Compact Framework

The .NET Compact Framework version 3.5 expands support for distributed mobile applications by including the Windows Communication Foundation (WCF) technology. It also adds new language features such as LINQ, new APIs based on community feedback, and improves debugging with updated diagnostic tools and features.

For details about these new features and enhancements, see What's New in the .NET Compact Framework Version 3.5

ASP.NET

The .NET Framework 3.5 includes enhancements in targeted areas of ASP.NET and Visual Web Developer. The most significant advance is improved support for the development of AJAX-enabled Web sites. ASP.NET supports server-centric AJAX development with a set of new server controls and APIs. You can enable an existing ASP.NET 2.0 page for AJAX by adding a ScriptManager control and an UpdatePanel control so that the page can update without requiring a full page refresh.

ASP.NET also supports client-centric AJAX development with a new client library called the Microsoft AJAX Library. The Microsoft AJAX Library supports client-centric, object-oriented development, which is browser-independent. By using the library classes in your ECMAScript (JavaScript) you can enable rich UI behaviors without roundtrips to the server. You can mix the degree of server-centric and client-centric development to meet the needs of your application. Furthermore, Visual Web Developer includes improved IntelliSense support for JavaScript and support for the Microsoft AJAX Library.

ASP.NET and Visual Web Developer now support the creation of both ASMX and WCF-based Web services and the seamless use of either implementation from Web pages using Microsoft AJAX Library. Furthermore, server-side application services including forms authentication, roles management, and profiles are now exposed as Web services that can be consumed in WCF-compatible applications, including client script and Window Forms clients. ASP.NET enables all Web-based applications to share these common application services.

Saturday, January 19, 2008

How to share one Internet connection with another computer using Vista?

If you have more than one computer at home and have only one internet connection, you might be wondering how to use internet in both the computer.
Let’s assume there are two computers A and B. Computer A runs on Windows Vista and Computer B runs on Windows XP.

Computer A is connected to Internet via cable, so this will be connected through a LAN card. Now to connect computer B, you will need another LAN card in computer A or if you want to connect to more than one computer, you will need a wired hub.

First let me explain how to connect two computers in LAN.

Step 1: In Vista, before doing this you should enable Sharing and Discovery. You can do that by going to Control Panel -> Network and Sharing Center. Under the section ‘Sharing and Discovery, enable Network discovery, File Sharing, Public folder sharing and others if you want to. (See picture below)




Here, first network represents connection to internet and second one the local connection with another computer.

Step 2: If your LAN card that is connecting to another computer is installed, it will be shown under Control Panel -> Network Connections.

Step 3: Right click that local area connection and click properties.

Step 4: Under the tab ‘Networking’, click the properties Internet Protocol Version 4 (TCP/IPv4).

Step 5: Click the radio button to ‘Use the following IP’ and give an IP address (For example, IP address: 192.168.0.1 and Subnet Mask: 255.255.255.0)

Step 6: Don’t give any other information, Click Ok and close everything.

Step 7: In computer B, make sure you enable the LAN card which is used to connect to computer ‘A’. Here you need not give any IP information as Computer ‘A’ will assign an IP address dynamically. If it’s not working make sure there are no IP assigned and change the properties to ‘Obtain an IP address automatically’.

Step 8: Test the connection by pinging. (You can do this by typing ping 192.168.0.1 or whichever is Compter ‘A’s IP in the comand prompt)

Sharing the Internet connection of computer ‘A’ with computer ‘B’:

Right click LAN card which is connected to Internet under Control Panel -> Network Connections and click ‘Sharing’ tab and enable both the options to share Internet. (Note: Unless there is another enabled LAN setting you will not be able to see the shared tab under properties)

Click Ok and close. This option is given by the Windows OS known as ICS (Internet Connection Sharing).

Now you can use Internet from both Computer A and Computer B from a single connection.

Wednesday, January 02, 2008

Configuration of SMTP Server using CDO.Message

We can set the settings of SMTP Server as given below:

Mail.SmtpMail.SmtpServer = "Give ur SMTP Server port if u have " or else give 127.0.0.4 or SMTPOut.SecureServer.Net

newMail.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

newMail.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

newMail.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "ur Smtp user name"

newMail.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "ur SMTP Server Password"


Note: For testing in ur Local System u can set the Outlook Email Id as ur userName and Outlook Password as ur Password for sendusername and sendpassword

Hope this answered ur question..