If you have received the error "Unable to create the Website...To access local IIS Websites, you must run Visual Studio in the context of an administrator account.", you must be running Windows Vista and trying to create a website in the local IIS.
I have been encountering this error often although it is well documented (hard to find?) And time and again, I realize that I need to run Visual Studio under the admin priveleges by elevating it, to create website in the IIS. Hence thought of posting this.
In Windows Vista, by default the applications dont run under the admin priveleges even though you are logged in as an administrator.
To elevate the priveleges, you would require to find Visual Studio from the Start - All Programs - Menu, Right click on the Visual Studio icon and select "Run as administrator", Click "Continue" for the UAC prompt and thereafter you would be able to create websites in the local IIS.
Alternatively, you could also use the built-in cassini webserver to create/host the application in any folder and run it against the ASP.NET Development Server (notice the tiny icon that gets created in your systray) that gets created automatically for running/testing on local machines.
A nice shortcut has been posted by one of our MVPs at http://forums.msdn.microsoft.com/en-US/vsx/thread/501bb098-ccf0-4d6d-933d-dcde58d233e1/ which can be useful to avoid the above steps, everytime.
Cheers !!!
The much awaited Visual Studio 2008 SP1 and the .NET Framework 3.5 SP1 is now RTM !! While we have talked about the .NET 3.5 SP1 features for a long time now, the RTM release marks something special for Web Developers. You would be able to build and deploy real world applications and use some of the cool features like Dynamic Data.
Before installing Visual Studio 2008 SP1, it is recommended to run the Visual Studio 2008 Service Pack Preparation Tool. The tool can be downloaded from here This tool removes any earlier versions of the SP1 Beta and also prepares your system for installing the SP1.
What do I get installing this? Well, a whole bunch of stuff considering that this is just a Service Pack. Instead of me listing it down, there is a cool post by the Web Development Tools team that lists them over here
The Web Development Tools blog is one of the most important resources you need to follow. You can subscribe for the same at http://blogs.msdn.com/webdevtools/
Also, there is a new blog that is put up for Web Development Tips & Tricks. Check it out at http://blogs.msdn.com/webdevelopertips/
Cheers !!!
If you are like me and wanted a comparison on which edition of Windows Vista to buy, you could just visit the following Microsoft.com site http://www.microsoft.com/windows/windows-vista/compare-editions/default.aspx to get the best idea of the features you would like to have and decide accordingly.
Most of the editions today come with SP1. So, many of the compatibility issues with a lot of third party solutions have been fixed now.
The Windows Vista Ultimate, needless to say, is the best you could think of and if you are targetting Media Center, Collaboration etc., this is the one you should be going for.
Thought of posting this link since it took sometime for me to figure out even from the windows vista official website, this particular reference.
Cheers !!!
In case you have installed the .NET 3.5 SP1 and Visual Studio 2008 SP1 and are unable to find the Dynamic Data Website Template, you can install the latest version of the runtime from http://www.codeplex.com/aspnet/Wiki/View.aspx?title=Dynamic%20Data&referringTitle=Home
To explain it further, I had the December 2007 CTP installed which contained the Dynamic Data Runtime and Astoria, Entity Framework etc., All of these gets bundled into the .NET 3.5 SP1 Beta and you dont need the December 2007 CTP any longer. So I went ahead and uninstalled the December 2007 CTP.
Post the uninstallation, I was unable to find the "Dynamic Data Website" Template. After some research I found that instead of fixing the issue by installing/uninstalling SP1 Bits again, it was better to install the latest bits of the Dynamic Data Runtime from CodePlex. The other advantage is that, you also get the "Dynamic Data Website Wizard (Preview)" that allows you to configure a data driven website very quickly, by following the wizard steps.
I would experiment with these bits and post my experience in my further posts. Till then, happy exploring.
Cheers !!!
Was talking to a DLR Team member and stumbled upon his blog which interestingly focuses on DLR Hosting and how you can start writing a host for DLR. Here below is the link to his blog.
http://blogs.msdn.com/seshadripv/
If you are new to DLR, is it the Dynamic Language Runtime that would be a layer on top of CLR for creating and running Iron Python and Iron Ruby (currently limited, but extending to other languages in future) on .NET.
DLR would also be supported in Silverlight 2, currently in Beta which means you can program using Iron Python or Iron Ruby and create a Silverlight Plugin for your Web. If you want to play with the bits, you can download the same from http://www.codeplex.com/sdlsdk
Cheers !!!
p.s. A quick and dirty way of restarting my blog posting.
You may run into this error when trying to use the new DataPager control with a GridView or any other control, other than the ListView control. For a moment I couldn't believe that the DataPager cannot work with the GridView control. Then after a few moments of research found out that, the Data Pager control requires the Data Control to implement the "IPageableItemContainer" interface. This is a part of the System.Web.Extensions namespace that is shipped with .NET 3.5.
This interface is currently implemented only by the List View control. If you arent aware, ListView and Datapager are the new server controls in ASP.NET 3.5.
So, the solution is to use the Data pager control in combination with a List View control.
To read more about the "IPageableItemContainer" interface, check http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.ipageableitemcontainer.aspx
Using the Data Pager control with List View
The List View control is new in ASP.NET 3.5. It allows you to customize the output that is rendered by the data control. Traditionally a DataGrid / Grid View control renders HTML Tables which can be a little heavy over the internet. The List View allows you to define the Layout Templte and Item Template and optional Alternating Layout Template, Empty Data Template etc.,
Configuring the ListView Control
1. Start Visual Studio 2008 and select "File - New Website".
2. Chose ".NET Framework 3.5" in the dropdown on the top right of the "New Website" dialog and click "Ok"
3. It creates your Website and a Default.aspx is created.
4. Open the Default.aspx page and from the ToolBox, drag and drop a ListView control in the design view (The ListView control is under the "Data" section in the ToolBox. If you dont find it, make sure you selected the ".NET Framework 3.5" as the version as mentioned in Point 2 above. Since this control is new in ASP.NET 3.5, it wont be available if you had selected ".NET Framework 2.0" or .NET Framework 3.0" in the "New Website" Dialog.)
5. In the Design View, click the smart tag that appears next to the ListView control and select "DataSource" and chose "New DataSource" and then chose "Database" as Data Source Type
6. You can provide an ID under the "Specify an ID for the data source" textbox or leave the default one. Click Ok
7. In the "Chose your Data Connection" dialog, chose an existing connection or you could also create a "New Connection" by providing the necessary paramters, test the connection and click "Next"
8. Click "Next" and make sure you selected "Yes" under "Do you want to save the connection....." so that the connection string gets saved in the web.config file.
9. In the next screen you can chose an existing table or create a SQL procedure and do all the conditions / filtering that you want to apply.
10. Click "Finish" in the next screen to complete the Data binding process.
11. At this point if you try running the site, you would get an error contrary to the case with a DataGrid or a GridView since, both these controls just require the steps upto 10 above to start rendering the Data.
12. However, for the Listview, control we need to define the ItemTemplate and LayOutTemplate. We can either define them manually or use the Visual Studio desinger to do that.
13. Go back to the ListView in the Design Mode and click on the smart tag and click on "Configure ListView"
14. In the "Configure ListView" dialog, you can select a LayOut as well as Style. While the default is Grid, chose a Bulleted List or Flow Layout so that it can render lighter HTML accordingly.
15. Later you can switch back the Layout by again configuring the ListView. You can also manually define the Item Template and the LayOut Template.
Configuring the DataPager Control
1. Once you are done with the ListView control, you can either chose "Enable Paging" and select "Next/Previous" or "Numeric". When you select this, it automatically generates the DataPager control with the following settings:-
<asp:DataPager ID="DataPager1" runat="server">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True"
ShowLastPageButton="True" />
</Fields>
</asp:DataPager>
2. Since this is automatically placed within the "LayOut Template" of the ListView it automatically provides pagination for the ListView control.
3. You can also control the attributes of the DataPager such as PagedControlID, PageSize to manually control these settings.
4. The PagedControlID in the above case is automatically perceived as the "ListView1" within which the DataPager is placed.
5. The DataPager control can also be manually defined outside the scope of ListView1 and in that case, you need to manually set the "PagedControlID" to "ListView1" or whatever ID that is provided for the ListView control.
6. The PageSize is automatically set to 10 and you can manually override the same by providing the pagesize property.
7. The Fields need to be manually defined when the DataPager is manually added and configured to be used with the ListView control. There are 3 options, the "NextPreviousPagerField" or "NumericPagerField" or "TemplatePagerField". In case of "TemplatePagerField" you need to manually define the templates similar to custom paging. In fact it is custom paging implementation.
Once you have configured the above and when you run the page, the ListView appears with the DataPager control as configured and as you check the source, you would be able to notice that since we selected "Bullted List" an <li> markup is generated instead of HTML tables, tds etc.,
The ListView is one control that allows a great amount of customization of the output.
Scott Guthrie has written an excellent post on using the Listview to build a Product Listing page with screen shots which provides a great resource on using the List View and various customizations.
Cheers !!!
Some of you who attended my recent Innovation Days and MSDN Sessions have asked for the URL for the Web Development Helper utility that I used during my demos.
Shamelessly, I am posting the link for download (shame, since it is not something I wrote and rather used an existing tool).
Well, you can download the same from http://projects.nikhilk.net/WebDevHelper/Default.aspx
The main site is http://www.nikhilk.net/ and you can find tons of useful information in this site. Nikhil is the Principal Architect in the US Developer Division and one whom we all admire for this sheer brilliance.
A good way to restart my blog postings isnt it 
Cheers !!!

If you are working with Visual Studio 2008, you might be looking for the Web Control Library template that used to be quite apparent in Visual Studio .NET 2003 and kind of hidden under "File - New - Project - Windows - Web Control Library" in Visual Studio 2005. Check my earlier post on this http://geekswithblogs.net/ranganh/archive/2006/09/06/90370.aspx
Well, in Visual Studio 2008, this option is under "File - New - Project - Web - ASP.NET Server Control". Yeah that is the place you you would find the template to create a Web Control Library.
Thought this was again tricky to figure out and would help if I post the details over here.
Cheers !!!
One of the common queries I get across my sessions is that, the File Upload control doesnt work inside an Update panel. All of us would like to implement a Gmail File Upload kind of interface and when you try to implement a similar thing using UpdatePanel (which works like a charm for other activities), it simply doesn't work.
The behaviour is expected. The File Upload Control doesnt work inside an Update Panel due to security reasons and restrictions a browser implies. They dont allow Javascript files to directly access the files in an user's sytem and dont allow to modify or access the details of a file when working with the File Upload Control.
There are a couple of ways to solve this issue, one using Update Panel and Post Back Triggers and the other using Iframes.
1. Use Update Panel, File Upload Control and use a PostBackTrigger Control to force a postback only for the File Upload Control
This approach works well without much tweaking except for that, there would be a postback only for the File Upload Control. While the rest of the stuff happens asynchronously, using the UpdatePanel, when the user presses the "Upload" Button, the page will be refreshed. Let us examine how we can accomplish this. Place the following code within the <form> </form> tags in your ASP.NET Page.
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" Height="20px" onclick="Button1_Click" Text="Submit" Width="128px" />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<asp:FileUpload ID="FileUpload1" runat="server" />
<br />
<asp:Button ID="Button2" runat="server" Height="25px" onclick="Button2_Click" Text="Upload" Width="128px" />
<br />
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
<br />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="Button2" />
</Triggers>
</asp:UpdatePanel>
In the Code behind, add the following lines of code:-
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = TextBox1.Text;
}
protected void Button2_Click(object sender, EventArgs e)
{
FileUpload1.PostedFile.SaveAs(@"C:\test\"+System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName));
Label2.Text = FileUpload1.PostedFile.FileName;
}
If you run the above sample, you would notice that upon entering something in the TextBox and clicking "Submit" (Button1) the Label above the File Upload Content, shows the Text you typed, without a page refresh.
However, when you select a file and click on the "Upload" (Button2) Button, you would notice that a postback happens and the file gets posted to the "C:\Test\" folder and also the full path is specified in the Label 2.
In the above code, I have not taken any steps regarding validation, checking if file exists etc., since it just shows how you could accomplish File Upload within Update panel. In normal cases, you would write better code to accomplish a file upload feature.
2. Use Iframes and accomplish a truly Gmail Like File Upload Interface.
I thought of writing a post on this, but did a quick research and found that there are a few solutions posted by our MVPs / Community Folks and just thought of providing a link to the same.
http://vinayakshrestha.wordpress.com/2007/03/13/uploading-files-using-aspnet-ajax-extensions/
http://msmvps.com/blogs/luisabreu/archive/2006/12/14/uploading-files-without-a-full-postback.aspx
Note that this post doesnt claim any warranty / support for the above articles, though.
Cheers !!!
If you have worked with Visual Studio 2008 and tried creating Mobile Web Applications, you would have figured out that the "Mobile Web Form" template is missing. In the past, in Visual Studio .NET 2003 you had Mobile Web Forms that allow you to create webforms that can be rendered over different types of HTML, WML and XHTML capable devices.
Well, it is not shipped by default in Visual Studio 2008, but Omar Khan from the Web Development Tools Team has put up a few templates that can be downloaded and brings in those Mobile Templates required for creating mobile web applications.
You can download the templates from the Web Development Tools Team Blog Post here There is a "readme" file attached to each of the extracted Zip folders. But to make it simpler, once you install and unzip the package, you get a folder "ASP.NET Mobile Templates" and inside that you might find a bunch of folders.
Copy the Zip folders inside each of the "ASP.NET Web Application" Folders into your system's Visual Studio Templates folder. For instance, there is a folder for "ASP.NET Web Application CS". You need to copy the contents of this file into
c:\Documents and Settings\<username>\My Documents\Visual Studio 2008\Templates\ItemTemplates\Visual C#
Similarly you would copy the contents of the "VB" folder into the Visual Basic folder under "ItemTemplates" above.
Once you copy these and restart Visual Studio 2008, you would be able to get the "Mobile Web Form", "Mobile Web User Control" and "Mobile Web Configuration File" under "My Templates" in "Add New Item" Wizard.
Cheers !!!
We are delivering Virtual Tech Days on April 9th and 10th (http://www.virtualtechdays.com) delivering a series of webcasts on different tracks ranging from SQL - BI to Visual Studio for Devices. Infact the three important tracks are SQL Server 2008, Visual Studio 2008 and Windows Server 2008.
These would be in depth sessions covering specific topics on each of the above products. For Visual Studio we have dedicated tracks for Application Development and Lifecycle management using Visual Studio 2008 and VSTS. We also have a Web Development track focussing on ASP.NET, AJAX, Silverlight and the recently released ASP.NET MVC Framework Beta. There would also be a track for Visual Studio for Smart client Apps including Mobile Devices.
You could find the detailed agenda at http://www.virtualtechdays.com/agenda.aspx The good thing that we have heard from you folks about webcasts is that, it doesnt require you to travel anywhere and take out time from your hectic work schedule. You could attend all of these from the comfort of your desktop and learn about the exciting technologies and their application in your projects.
The sessions are going to be delivered along with Quiz, Contests etc., and there are exciting gifts promized and believe me, I feel its one good time to be attendee than a speaker for this event.
The whole event would be hosted by Mandira Bedi.
So, for more information and registration visit http://www.virtualtechdays.com/registration.aspx
Looking forward to see you all in the Virtual Tech Days.
Well, if you are a regular reader of my blog, you would have noticed that I have recently uploaded a few videos on Visual Studio and ASP.NET AJAX, powered by Silverlight. A lot of you might want to upload your videos into your web pages, web logs, site etc., and would be wondering on where to upload the videos, how to host it etc., Also, some of you might be waiting to use Silverlight in your website. Well, this post (inspired with my own experience) helps understand on how you can achieve both (use Silverlight as well as host videos on your webpages) together.
The first thing that you would require to upload a video, is obviously the Video. You may want to start recording a screen capture of a simple "How-to" technical article or even on a yummy recipe that you tried. You could record the video using any screen capture tool or can try the free Windows Media Encoder Series
Once you are done with recording a decent size video (say of size 3-4 MB), you are all set to start publishing the video.
Encoding your Video for Windows Live Streaming using Expression Encoder
1. Download Expression Encoder for free
2. Open Expression Encoder, select "File - "Import" and chose the location where you have your recorded video
3. It shows the Imported Video under the Media Content section
4. Select Settings in the right and under Profile adjust the Video and Audio to reduce the size. Typically anything more than 25MB is going to have issues when using Silverlight Streaming. So adjust the settings accordingly.
5. Switch to the Output tab and under Job Output - Template - chose a template for the video. I chose the Silverlight Template which looks cool.
6. Once you are done with the above, click Encode to encode the video file for streaming
7. The Encoded file is typically stored in Documents folder under Expression\Encoder folders.
8. A folder is created for every encoded video
9. When you navigate to this folder, you might find the following files
i. BasePlayer.js
ii. Default.html
iii. Your WMV Video file
iv. MicrosoftAjax.js
v. player.js
vi. player.xaml
vii. PlayerStrings.js
viii. project.csproj
ix. Silverlight.js
x. StartPlayer.js
10. We need to add a Manifest file to the above files.
11. Create a simple .txt file and rename it to manifest.xml. Open it using any text editor and copy paste the following contents
<SilverlightApp>
<version>1.0</version>
<loadFunction>StartWithParent</loadFunction>
<jsOrder>
<js>MicrosoftAjax.js</js>
<js>BasePlayer.js</js>
<js>PlayerStrings.js</js>
<js>player.js</js>
<js>StartPlayer.js</js>
</jsOrder>
</SilverlightApp>
Save this file
12. Secondly, you may not want the video to start playing automatically since it might be a little annoying for your visitors, particularly if there are more than a single video. To avoid this, you can edit the StartPlayer.js file and navigate to the section where it says autoPlay. It is set to true by default. Change it to false. This would make the video play after users click on the same.
13. Once you are done with the above changes, select all the files mentioned above (contents of the folder for this particular video) and Zip them. You would need to ignore the following files while zipping
i. Default.html
ii. Silverlight.js
iii. project.csproj file
14. The zipped file is what you would require to host your video
Silverlight Streaming
Silverlight Streaming is a free streaming resource provided by Windows Live Services It allows you to host upto 4GB Videos for free streaming and is an innovative approach since we take care of the streaming and hosting part. All one requires is a silverlight player installed on the client side to render your video.
You can get a Silverlight Streaming account for free from http://silverlight.live.com Once you create an account, visit the
Manage Applications section and select "Upload a Silverlight Application" link
You would require to provide a name which has no space (little annoying) without hyphen (even more annoying if you are used to using hyphens) and there after Browse to upload the zipped files.
Once you are able to upload the zip file successfully, you would get an URL with an iframe tag and the required properties.
Adding it to your website
Well, all you have to do is to copy the iframe URL provided in the Silverlight Streaming site and paste it into your blog template (switching to HTML View) / website.
Thats it, you could see that your videos are playing powered by Silverlight Streaming.
Happy Silverlight Streaming !!!
Click Here for a text version of this article !
Click Here for a text version of this article
Click Here for a text version of this article