Whidbey
Whidbey
In ASP.NET 2.0, you have multiple options to take your application offline.
- By setting httpruntime to false in web.config. For example,
- Using ASP.NET Configuration Site. In this configuration site, you have option to take your application offline in “Application Configuration” tab. This tab also shows whether your application is currently offline or online. Internally this configuration uses the first option to shutdown the application i.e by setting httpruntime to false. To know more about ASP.NET Configuration. Check out this article.
- Third option is by creating an empty htm page named app_offline.htm in your root directory. If this htm page contains any content, then that content is displayed instead of 404 error.
Advantages of all these options are, it doesn’t shutdown the whole process in which your web application is running. It just shuts down the appdomain of your web application. Hence other applications which runs along with your application in the process runs without any problem. These options can be used when you are doing maintenance on your site.
Note: If you web application gives 404 error, then check whether any one of this options is enabled. Actually, copy web site in ASP.NET 2.0 internally uses app_offline approach and sometime it leaves that file in the root directory. When you access your site after copy web site operation, you might get offline message. Then check out for this dummy page and remove it.
When you access Source Control Explorer in VS.NET 2005 Beta2, sometimes you might the following error.
Exception has been thrown by the target of an invocation.
You might be wondering why this error occurs and it wont occur always. This error comes only when you try to open Source Control Explorer without connecting to TFS. To avoid this problem, always activate team explorer window (internally it will connect to TFS) and then access Source Control Explorer.
Actually, Source Control Explorer should automatically connect to TFS when we open Source Control Explorer. Probably in the beta3 (which is supposed to be released along with VS.NET 2005 RTM) it might work that way.
In whidbey, ASP.NET Project Start option has come up with additional option "Use Current Page". When you set this option and run/debug your project, VS.NET will start with the current aspx page that you are working on. If you are working on codebehind file, it will open the corresponding aspx page.
To go to Start option: Select Web Project --> Choose Property Pages option [shortcut Alt-Enter] --> In the property pages, select start option.
Using this feature, you need not select “Set as Start Page" option whenever you want to switch between aspx pages. This option is very useful when you are showing demo where you need to run different aspx pages for each demo. Whenever you change the aspx page for demo, it will start with that aspx page.
Default start option is "Use Current Page", but once you use "Set as Start Page" option in VS.NET. Start option will change to "Specific Page" and it will point to the selected page. In this option, though you move between aspx pages in VS.NET, it will always open with the specified page.
Another tip for "Specific Page" option is, you can specify query string parameter along with the url. This feature is very useful when you want to run/debug an aspx page, which requires querystring parameter for its operation. This feature is available in vs.net 2003 also.
Panel web server control in ASP.NET 2.0 is coming with a new property "GroupingText", using this property you can set the title for the panel. Panel controls are used to group related controls in a web form. If you set a title for these groupings, it will look better. Using "GroupingText" property you can achieve this.
This feature is implemented using FieldSet and Legend html elements. When the GroupingText property is set in panel control, ASP.NET emits FieldSet and Legend html elements in the response to set the title for the panel.
For example, when you define a panel like this,
<asp:Panel GroupingText="Address" runat=server ID="AddressPanel">
<! -- Child Controls -->
</asp:panel>
HTML output for the panel will be.
<div id="AddressPanel">
<fieldset>
<legend>
Address
</legend>
<!-- Child Controls -->
</fieldset>
</div>
Get a focused, first look at the features and capabilities in Microsoft Visual Basic 2005, Visual Studio 2005, and .NET Framework 2.0. If you currently work with Visual Basic 6, these authors fully understand the adoption and code migration issues you’ll encounter. They’ll step you through a quick primer on .NET Framework programming, offering guidance for a productive transition. If you already work with .NET, you’ll jump directly into what’s new, learning how to extend your existing skills. From the innovations in rapid application development, debugging, and deployment, to new data access, desktop, and Web programming capabilities, you get the prerelease insights and code walkthroughs you need to get productive right away.
Click here to start reading this book,
For development, Visual Studio 2005 now comes with a built-in development-only Web server. This lightweight Web server can only respond to local requests and is therefore not a security threat. The server does, however support full debugging features and can be used as a development tool for new Web applications. When you are ready to test out scalability and performance or deploy for production, simply move the application to IIS.
If the asp.net application is not deployed in IIS and you try to run the asp.net application from Visual Studio 2005, the local development web server will be started automatically. If local web development server is automatically, it will pick up the port number randomly and run the development server in that port.
However, in some situations you might require to start this web server manually. For example, you might want to run this local web server in certain port or if you want to test the web page without opening VS 2005.
In those cases, you can use WebDev.WebServer.Exe located in
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50215 (this path might vary depending upon the .net framework installation) to start this web server manually. This is the executable for local development web server; even VS 2005 internally uses this executable to start the local web server.
This command line executable accepts three parameters,
1. path : Physical path of the application which you want to run.
2. port : port in which you want to start this web server. Default is 80.
3. vpath: Specify application root using this option. Default is "/"
For example, to start a web application located at c:\temp\testing and in the port 8001.
WebDev.WebServer.EXE /path:D:\temp\Testing /port:8001 /vpath:/testing
After you run this utility, you can see ASP.NET development Web server in the system tray. You can access your web application from the browser using http://localhost:8001/testing/
Problem: ASP.NET Development Server gives one of the following errors when you try to run your web application.
- 404 error though the web pages are there in your application
- Cannot find server or DNS Error
- Timeout error
Solution to this problem is to disable the NTLM Authentication for your web application. NTLM authentication is enabled by default for your application.
To disable the NTLM Authentication, follow the steps below
- Open your web application in VS 2005
- Right click on your web application and select the property pages
- Go to Start options
- Go to Server Section
- In that, disable NTLM Authentication.
This workaround will work most of the time.
I am still thinking why NTLM Authentication is not working even in IE forASP.NET Development Server.
In .NET 1.x, most of you would have created a utility function for doing the following two things
- Check for dbnull
- Typecast the value to required data type or return the default value in case of dbnull.
For example,
// return default value for integer if the object is null
public int DBCheckforInt(object i)
{
if (i == System.DBNull.Value)
return 0;
else
return (int)i;
}
// return default value for decimal if the object is null
public double DBCheckfordouble(object o)
{
if (o == System.DBNull.Value)
return 0.0;
else
return (double)o;
}
Note: For performance reason, you need to use System.DBNull.Value instead of using IsDBNull() function to check for dbnull. More details here.
Major disadvantage with this approach is, we need to create a function for each datatype that we require to check for dbnull. However, the logic is same for all the datatype. In whidbey, generics helps us to solve this kind of problem i.e. you can can pass data type as parameter to that function. In that function depending upon the datatype, return the default value for that datatype or typecast and return the value. For example, same utility function in whidbey will be
public static T DBNullCheck<T>(Object obj)
{
return obj == System.DBNull.Value ? default(T) : (T)obj;
}
In whidbey, it is one function for all the data types. default is the keyword in whidbey returns the default value for the specified datatype. To know more about genercis, check out these articles on generics,
- CLR and Language Enhancements in Whidbey
- Generics Internals
One problem with this method is, for String it returns default value as null. In some cases, we might have String.Empty as default value for String. In those cases, this method might not be useful. But for all other primitive data types, this method will work.
From beta2, VB.NET Code Snippet Editor is available as a standalone windows application. You can download it from here. If you are not aware of Code Snippet Editor, it is a Windows Forms application with UI for creating, editing, testing VB code snippets. If you want to know more about code Snippets, check out my articles "Code Snippets in VB.NET 2005" Part1 and Part2
Actually, during pre beta, this snippet editor was integrated with VS.NET 2005. You can invoke this editor from code editor by selecting Create Snippet menu option from context menu. I have mentioned about this in my article "Code Snippets in VB.NET 2005". Now it is moved out of VS.NET 2005. I dont know why MS has done this, I feel it will be better if VB.NET Code Snippet Editor comes along with IDE. I am trying to integrate this tool with VS.NET IDE. if i succeed, i will post the details.
One of the important features that was missing in VB.NET 2005 was refactoring though "Rename" capability was there.. But now Microsoft joined with Developer Express Inc and released a free plugin "Refactor! for Visual Basic 2005 Beta 2" to support refactoring. This tool supports following refactoring operations,
- Reorder Parameters
- Extract Method
- Extract Property
- Create Overload
- Surrounds With (Not available in BETA 2 release)
- Encapsulate field
- Reverse Conditional
- Simplify expression
- Introduce Local
- Introduce constant
- Inline Temp
- Replace Temp with Query
- Split Temporary Variable
- Move initialization to declaration
- Split initialization from declaration
- Move declaration near reference