My client needs to be able to restrict page content based on the client machine name on their intranet site. I knew that you could get the IP address from the REMOTE_HOST HTTP header, and some exploration of the System.Net namespace revealed that you can use the System.Net.Dns.GetHostByAddress method to perform a reverse DNS look up to get the machine name. Here’s a VB.Net example:
Dim strIp As String
Dim he As System.Net.IPHostEntry
Dim strHostName As String
strIp = Me.Request.ServerVariables("REMOTE_HOST")
he = System.Net.Dns.GetHostByAddress(strIp)
strHostName = he.HostName
I can’t believe this blog has been up for 5 months, and I haven’t posted anything about GIS – since I come from a GIS programming background. It is even more telling that this post is about how to get around using GIS software by using ASP.Net, SQL Server, and the Google API to geocode addresses!
Check out this post about Geocoding with SQL Server on John Sample’s (is that his real name?) blog.
Two methods for sharing session variables between ASP and ASP.Net pages.
I’m working on a major ASP to ASP.Net conversion project that can only really be done one page at a time. One of the obstacles to doing it this way was sharing session variables between ASP and ASP.Net pages.
Most solutions to this common problem involve intermediary pages that write the session variables of one type into form variables and then from form variables back into session variables of the other type (See Peter A. Bromberg’s example on eggheadcafe.com).
Microsoft’s Billy Yuen’s solution uses SQL Server as a repository for session data, and provides custom objects for both ASP and ASP.Net to access the session data.
Ultimately, we abandoned this since the site’s use of session variables was minimal and there were other ways of solving the problems we were using session state for.
I am currently writing my ASP.Net pages in VB.Net since my client comes from the ASP/VBScript tradition and the VB syntax is more familiar to them. It hasn’t taken long for me to miss the terse syntax of C#, especially since I have mild tendonitus and typing all those End X is killing me. Properties are the worst. Even though VS.Net will complete properties that you start in VB, you still have to write one line for each to get them started. So I looked to the web for a solution to this problem, and low and behold, I found this great article by Scott Mitchelle on using VS.Net macros to write properties.
I took this concept and expanded it by writing a macro that will write the property shells for all the private member reocords you have selected. Click here to download the macro.
I’m surprised how hard it is to find a good tech PodCast that talks about coding and best practices. I stumbled upon Craig Shoemaker’s Polymorphic PodCast first, and haven’t found anything that comes close to the quality of its content since. I think his show should make it somewhere higher thank #27 on Podcast Alley’s list of top tech podcasts. Of course, I’m going to be biased towards shows that cover the technologies I develop in (.Net, Oracle, etc.) so perlcast and anything with mac in the title are out for me. But half the shows on that list are mostly music (i.e. daily source code).
Too bad the .Net show won’t podcast just because the word "pod" is in the title.
I’m developing an ASP.Net site for a client that is very concerned about bandwidth. My first objective is to reduce the size of the hidden veiwstate data returned in the form.
The worst culprits seem to be the data display controls, especially the DataGrid. I found that for displaying small amounts of data in a table (20 rows by 5 columns) the page with a DataGrid returned over twice as much view state data (5,716 bytes vs 2,512 bytes) as one using a Repeater to render the table.
Worse yet, once I started returning larger amounts of data, even the Repeater was generating a heafty amount of veiw state data. Since these pages are essentially run once search result pages, I’ve added the following to the Page directive
ASP.Net still returns view state data for the page, but only a small amount. To completely remove it from the page, you have to remove all runat=”server” tags.
The following article also shows how to trim the ViewState data on a control by control basis:
DataSets offer disconnected functionality, but DataReaders offer speed according to Why I Don’t Use DataSets in My ASP.NET Applications
By Scott Mitchelle
This example demonstrates recursively iterating through files and sub-directories in a given directory using the DirectoryInfo class.
Generate your own PDF documents on the fly!
Generate your own PDF documents on the fly with the Gios Pdf.NET C# code library. I haven’t tried it, but I’m sure this comes in handy for reporting.
A list of migration resources from gotdotnet.com.
On the list is Migrating to ASP.NET: Key Considerations from MSDN.