Friday, October 30, 2009

Clean Web.Config Files (VS 2010 and ASP.NET 4.0)

You’ll encounter this improvement the first time you do a File->New Project within Visual Studio 2010 and create an empty ASP.NET 4.0 Web application (which is why I thought it might be appropriate to-do as the first post).

Web.config files in .NET 3.0 and 3.5
Over the last few releases, the web.config files within new ASP.NET projects have steadily increased in size. For example: the default web.config file that is added to a new web project in Visual Studio 2008 SP1 is now some 126 lines long, and contains everything from tag definitions to definitions of handlers and modules to be included in the ASP.NET HTTP pipeline.


This increase in size is because .NET 3.0 and .NET 3.5 use the same CLR and machine.config configuration file as those shipped with .NET 2.0 – and simply add and update assemblies in the framework when they are installed. To avoid the risk of us accidentally overwriting customized settings within the original 2.0 machine.config on the machine, we didn’t register the tag definitions, handlers and modules that shipped with the new ASP.NET functionality that came with the .NET 3.0 and .NET 3.5 versions. Instead, we defaulted to having new projects register these settings within the application’s local web.config file instead. This was safer – but caused the web.config files to increase and become more complicated and harder to read.


Web.config files in .NET 4
.NET 4 includes a new version of the CLR, and a new .NET 4 specific machine.config file (which is installed side-by-side with the one used by .NET 2, .NET 3 and .NET 3.5).



The new .NET 4 machine.config file now automatically registers all of the ASP.NET tag sections, handlers and modules that we’ve added over the years, including the functionality for:

ASP.NET AJAX
ASP.NET Dynamic Data
ASP.NET Routing (which can now be used for both ASP.NET WebForms and ASP.NET MVC)
ASP.NET Chart Control (which now ships built-into ASP.NET V4)


What this means is that when you create a new “Empty ASP.NET application” project in VS 2010, you’ll find that the new default application-level web.config file is now clean and simple:


Thursday, October 29, 2009

Sharepoint 2010

SharePoint 2010 Sneak Peak

I guess this will be blogged extensivly the coming hours and days: Microsoft has released official documentation about the next version of SharePoint. Read all about it here:
http://sharepoint.microsoft.com/2010/Sneak_Peek/Pages/default.aspx. From that site:

General overview SharePoint 2010 enables organizations to connect and empower people through an integrated set of rich features. Get a sneak peek of SharePoint 2010 product features today.

For IT Professionals For IT professionals, SharePoint 2010 offers enhancement to drive productivity, scalable unified infrastructure, and flexible deployment. Learn more about how to cut IT costs with SharePoint 2010.

For Developers YAY!For developers, SharePoint 2010 provides the business collaboration platform to rapidly build solutions and respond to business needs. Check out SharePoint 2010 features sneak peek for developers.

Wednesday, October 28, 2009

Sharepoint tutorial...

Are you new to Sharepoint??? Wanna to begin with Sharepoint development??? If yes then click on below link. There is plenty of information to begin with Sharepoint.

http://www.microsoft.com/click/SharePointDeveloper/

Enjoy and happy reading... :)

Wednesday, September 2, 2009

enableWebScript, UriTemplate, and HTTP methods

I got very nice post on enableWebScript from Justin Smith blog so I have posted it on my blog:

A little while ago I ran into an interesting set of errors that may be of interest to you. Consider the following service contract snippet:

[OperationContract]
[WebGet(UriTemplate="foobar/{value}")]
String GetData(String value);

If you add the enableWebScript behavior to an endpoint that is using the WebHttpBinding, you will see this exception when the ServiceHost starts:

System.InvalidOperationException: Endpoints using 'UriTemplate' cannot be used with 'System.ServiceModel.Description.WebScriptEnablingBehavior'.

The reason for this error is rooted in the origin of the enableWebScript behavior. One of it's design objectives was to simplify working with the ASP.NET AJAX stack (Javascript proxy, JSON messages, etc). The AJAX stack doesn't have the equivalent of the UriTempalte type. It simply puts parameters in query strings (gets) and constructs entity bodies (posts). This is the default behavior of the WCF stack when the WebGet / WebInvoke annotations do not have a value for UriTemplate. Since any value of UriTemplate would be incompatible with the ASP.NET AJAX stack, we throw when it's present.

If you want JSON messages from a contract and you want to use the UriTemplate niceness, you can change your contract to:

[OperationContract][
WebGet(UriTemplate="foobar/{value}", ResponseFormat=WebMessageFormat.Json)]
String GetData(String value);

Then, instead of using the enableWebScript behavior, use the WebHttpBehavior. You'll lose compat with the ASP.NET AJAX client stack (and the JS proxy), but you have the URI you are looking for.

The same is true if you are using the WebInvoke attribute and any HTTP method other than POST. The AJAX client stack only knows GET and POST...

HTH...

Happy coding... :)


Tuesday, May 26, 2009

Listen Radio Mirchi !!! (Open in IE only)
















enjoy...

Thursday, May 7, 2009

ADO.NET Data Services Videos

Hi,

I found ADO.NET Data Service Videos at following link:
http://msdn.microsoft.com/en-us/data/cc300162.aspx

Enjoy!!!

Tuesday, April 7, 2009

Can not create or open silverlight 2 projects "Object reference not set to a instance of an object"

Problems:When you create a new silverlight project you get a message "Object reference not set to a instance of an object"When you try to load existing project it tells that visual studio can not open this type of project.

Solution:
(a) Open the command prompt and go to the folder C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE


(b) type devenv /resetskippkgs

close the Visual Studio Window that will open after completion of previous command.

(c) type devenv /setup

(d) After the execution of previous command is complete open Visual Studio.


Cheers!!!

Monday, March 9, 2009

Send Email in .Net Application without SMTP server

Usually, when we send an email, we need to have valid SMTP server along with access and deliver the email using that server. If we add the send email functionality to software, the user needs to configure an SMTP server address, the username, and the password. The SMTP server receive message and send it to another SMTP server or deliver it to local inbox. Why not send an email to the receiver's SMTP server directly? Why can’t we directly communicate to receiver SMTP server on port 25?

The problem is we don't know which SMTP server is responsible for receiving emails for a given email address. The secret is that this information can be obtained from Domain Name System (DNS) servers. This seems simple; however, it needs a lot work to implement the DNS protocol (
RFC 1035) because the .NET framework doesn't support getting mail server info from DNS.

There are certain fundamental concepts defined for SMTP
RFC 5321 SMTP servers which send message to another server are called MTAs. MTAs look for MX record (may find more than one MX records) for the domain (DNS look up for NS and MX record, in windows you can use dnsapi.dll, DnsQuery_W method suits to needs.). Once you have server IP you can connect to port 25 (generally those ports are Ephemeral) and exchange message (of course according to RFC 5321).

We can use Dnsapi.dll to query DNS server the code is....

/* **********************************************
* Developed by Dipak Bava
* Resolves MX records for domain name
* Date: 25 Feb 2009
* **********************************************/
using System;
using System.Collections;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace SendSMTP
{
public class DnsLookUp
{
public DnsLookUp()
{
}
[DllImport("dnsapi", EntryPoint = "DnsQuery_W", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
private static extern int DnsQuery([MarshalAs(UnmanagedType.VBByRefStr)]ref string pszName, QueryTypes wType, QueryOptions options, int aipServers, ref IntPtr ppQueryResults, int pReserved);

[DllImport("dnsapi", CharSet = CharSet.Auto, SetLastError = true)]
private static extern void DnsRecordListFree(IntPtr pRecordList, int FreeType);

public static string[] GetMXRecords(string domain)
{

IntPtr ptr1 = IntPtr.Zero;
IntPtr ptr2 = IntPtr.Zero;
MXRecord recMx;
if (Environment.OSVersion.Platform != PlatformID.Win32NT)
{
throw new NotSupportedException();
}
ArrayList list1 = new ArrayList();
int num1 = DnsLookUp.DnsQuery(ref domain, QueryTypes.DNS_TYPE_MX, QueryOptions.DNS_QUERY_BYPASS_CACHE, 0, ref ptr1, 0);
if (num1 != 0)
{
throw new Win32Exception(num1);
}
for (ptr2 = ptr1; !ptr2.Equals(IntPtr.Zero); ptr2 = recMx.pNext)
{
recMx = (MXRecord)Marshal.PtrToStructure(ptr2, typeof(MXRecord));
if (recMx.wType == 15)
{
string text1 = Marshal.PtrToStringAuto(recMx.pNameExchange);
list1.Add(text1);
}
}
DnsLookUp.DnsRecordListFree(ptr1, 0);
return (string[])list1.ToArray(typeof(string));
}

private enum QueryOptions
{
DNS_QUERY_ACCEPT_TRUNCATED_RESPONSE = 1,
DNS_QUERY_BYPASS_CACHE = 8,
DNS_QUERY_DONT_RESET_TTL_VALUES = 0x100000,
DNS_QUERY_NO_HOSTS_FILE = 0x40,
DNS_QUERY_NO_LOCAL_NAME = 0x20,
DNS_QUERY_NO_NETBT = 0x80,
DNS_QUERY_NO_RECURSION = 4,
DNS_QUERY_NO_WIRE_QUERY = 0x10,
DNS_QUERY_RESERVED = -16777216,
DNS_QUERY_RETURN_MESSAGE = 0x200,
DNS_QUERY_STANDARD = 0,
DNS_QUERY_TREAT_AS_FQDN = 0x1000,
DNS_QUERY_USE_TCP_ONLY = 2,
DNS_QUERY_WIRE_ONLY = 0x100
}

private enum QueryTypes
{
DNS_TYPE_MX = 15
}

[StructLayout(LayoutKind.Sequential)]
private struct MXRecord
{
public IntPtr pNext;
public string pName;
public short wType;
public short wDataLength;
public int flags;
public int dwTtl;
public int dwReserved;
public IntPtr pNameExchange;
public short wPreference;
public short Pad;
}
}
}

Sounds good up to here but when you really try to connect MTAs to deliver message spamhaus comes in to picture. Most of the MTAs are now intelligent enough to fight against spammer and your ISP could be in the radar. So before you try, it’s wise to check you IP with http://www.spamhaus.org/query/bl?ip=xx.xx.xx.xx
Use the following code to deliver message if you do not want to study RFC 5321.

//Now prepare your message.
MailMessage mail = new MailMessage();
mail.To.Add("someone@somedomail.com");
mail.From = new MailAddress("tome@somedomain.com");
mail.Subject = "Send email without SMTP server";
mail.Body = "Yep, its workin!!!!";

//Send message
string domain = mail.To[0].Address.Substring(mail.To[0].Address.IndexOf('@') + 1);
//To Do :need to check for MX record existance before you send. Left intentionally for you.
string mxRecord = SendSMTP.DnsLookUp.GetMXRecords(domain)[0];
SmtpClient client = new SmtpClient(mxRecord);
client.Send(mail);

Best Luck
Dipak Goswami

Thursday, February 26, 2009

VS2008 ShortCut Keys for VB.NET and C#.NET

Hi Friends,

Wanna to imrove your productivey? Wanna to improve your navigation speed in Visual Studio? Wanna to impress your friend/colleauge???

Here are links for files which contains all short-cut keys of VS2008 for VB.NET and C#.NET:



Enjoy Coding !!!

Tuesday, February 24, 2009

MCTS (Web Developer) Materials

Hi Friends,

Wanna to become Microsoft Certified Professional???

Here you will find material for MCTS - Web Developer (70-528 and 70-536):




Happy Certifications !!!! :)

ASP.NET and JQuery

JQuery is an open source JavaScript library that has a passionate following among Ajax developers. Microsoft is integrating the open source JQuery library into both the ASP.NET Web Forms and ASP.NET MVC frameworks and providing full product support. Learn how you can take advantage of JQuery to build richly interactive client-side Ajax applications when developing either ASP.NET Web Forms or ASP.NET MVC applications. Also see how JQuery works in combination with ASP.NET AJAX to provide the best framework for building Ajax applications. Watch following video to learn JQuery and ASP.NET:
http://channel9.msdn.com/pdc2008/PC31/

The official site of JQuery is: http://jquery.com/.

Wednesday, February 18, 2009

Microsoft LINQ Webcasts

(1) Using LINQ with Relational Data
MSDN Webcast: One of the most common forms of data used in applications today continues to be relational data that is stored in various database systems such as Microsoft SQL Server. In this session, learn about the flavors of LINQ that are designed to access relational data including LINQ to SQL, LINQ to Datasets, and LINQ to Entities.

http://msevents.microsoft.com/cui/WebCastEventDetails.aspx?EventID=1032369773&EventCategory=4&culture=en-US&CountryCode=US

(2) Framework Masterclass: LINQ to XML
MSDN Webcast: “Framework Masterclass: LINQ to XML,” presented by Mike Benkovich (a MSDN Developer Evangelist). Topics include how LINQ can help you to develop XML applications, the basics of the XML helper functions and more.

http://msevents.microsoft.com/cui/WebCastEventDetails.aspx?culture=en-US&EventID=1032349381&CountryCode=US

(3) Framework Masterclass: LINQ to Entities
MSDN Webcast: “Framework Masterclass: LINQ to Entities,” presented by Mike Benkovich (a MSDN Developer Evangelist). This webcast discusses connecting to the data access layer and how to enhance LINQ applications by working with entities.

http://msevents.microsoft.com/cui/WebCastEventDetails.aspx?culture=en-US&EventID=1032349385&CountryCode=US

(4) Framework Masterclass: LINQ to SQL
MSDN Webcast: Microsoft .NET Language Integrated Query (LINQ) provides a common way to work with data in your applications. In this session, we dive into how LINQ provides methods to work with Structured Query Language (SQL) databases, including how to query, insert, and manage data using the LINQ framework.
http://www.microsoft.com/events/series/detail/webcastdetails.aspx?seriesid=113&webcastid=3952

Happy Watching!!!

WCF Webcast Videos

Hi Guys,

I found links of 15 WCF webcast videos. It will required your sign in on Micorosoft site so you needs live id. Once you logged in you can download those webcasts also!!!


Here are links of webcast videos:

(1) MSDN Webcast: Windows Communication Foundation: Overview
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344312&Culture=en-US

(2) MSDN Webcast: Windows Communication Foundation: Contracts
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344314&Culture=en-US

(3) MSDN Webcast: Windows Communication Foundation: Contract Versioning
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344318&Culture=en-US

(4) MSDN Webcast: Windows Communication Foundation: Exceptions and Faults
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344322&Culture=en-US

(5) MSDN Webcast: Windows Communication Foundation: Bindings
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344330&Culture=en-US

(6) MSDN Webcast: Windows Communication Foundation: Hosting
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344338&Culture=en-US

(7) MSDN Webcast: Windows Communication Foundation: Messaging Patterns
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344342&Culture=en-US

(8) MSDN Webcast: Windows Communication Foundation: Instancing Modes
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344344&Culture=en-US

(9) MSDN Webcast: Windows Communication Foundation: Concurrency, Throughput, and Throttling
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344346&Culture=en-US

(10) MSDN Webcast: Windows Communication Foundation: Security Fundamentals
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344348&Culture=en-US

(11) MSDN Webcast: Windows Communication Foundation: Federated Security
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344351&Culture=en-US

(12) MSDN Webcast: Windows Communication Foundation: Reliable Messaging
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344353&Culture=en-US

(13) MSDN Webcast: Windows Communication Foundation: Transactions
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344355&Culture=en-US

(14) MSDN Webcast: Windows Communication Foundation: Message Queuing
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344357&Culture=en-US

(15) MSDN Webcast: Windows Communication Foundation: Extensibility
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344359&Culture=en-US

Enjoy Watching!!!

Thursday, January 8, 2009

3-Tier Architecture Demo using Generics

Hi Guys,
Happy New Year to all of you.

3-Tier architecture is very old and famous architecture in programming field. As we know, it contains 3 layers:

(i) Presentaion Layer: Contains .aspx and .ascx files (Don't use DataSet, DataTable or DataReader in Presentation Layer)

(ii) Business Layer: Contains Business classes (Write all business logic here instead of presentation layer)

(iii) Data Layer: Contains Data related classes and logic (All Database operations)

I have created 3-Tier demo application using Generic and some of .NET 3.5 features. You can download source code of demo application from following link:





Steps:
(i) Open solution in VS2008 as I have developed it using VS2008.
(ii) There is one SQL Script file under App_Data folder. Execute that script file which creates database and its objects.
(iii) See the flow of architecture, please don't do any testing as I have not done unit testing of application.

(iv) I have not used many oops concepts to make demo as simple as possible.