KBD

Keith Devens .com

Saturday, July 19, 2008 Flag waving
Don't panic. – Douglas Adams (The Hitchhiker's Guide to the Galaxy)

Tag: ASP.NET

Parents:

Daily link icon Monday, June 23, 2008

  1. Jayrock: JSON and JSON-RPC for .NET.

       (0) Tags: [ASP.NET, Json]

Daily link icon Friday, January 18, 2008

  1. 15 Seconds : Tuning Up ADO.NET Connection Pooling in ASP.NET Applications.

       (0) Tags: [ASP.NET]

Daily link icon Friday, January 11, 2008

  1. ASP.NET AJAX Control Toolkit.

       (2) Tags: [ASP.NET, Javascript]

Daily link icon Thursday, June 8, 2006

  1. Geekpedia • ASP.NET: The name 'Session' does not exist in the current context. I think this'll happen in particular if you're trying to access Session from a class defined in App_Code. Use HttpContext.Current.Session instead.

       (2) Tags: [ASP.NET]

Daily link icon Wednesday, June 7, 2006

  1. PageMethods, well-defined URLs for your ASP.NET sites by metaSapiens. Looks pretty neat. It seems to work something like the URI to object method call frameworks that exist for other languages.

       (0) Tags: [ASP.NET]

Daily link icon Tuesday, May 2, 2006

  1. MonoRail:

    MonoRail (former Castle on Rails) is a MVC web framework inspired on Action Pack. The Action Pack way of development is extremely productive, very intuitive and easily testable.

    MonoRail differs from the standard WebForms way of development as it enforces separation of concerns; controllers just handle application flow, models represent the data, and the view is just concerned about presentation logic. Consequently, you write less code and end up with a more maintainable application.

       (0) Tags: [ASP.NET, Ruby on Rails]
  2. Cassini Web Server - Free Redistributable ASP.NET Web Server from UltiDev LLC.

       (0) Tags: [ASP.NET]

Daily link icon Monday, April 17, 2006

How to do clean URIs in your ASP.NET application

It's actually very simple to do clean URIs in an ASP.NET application. In your Global.asax file:

string root = "/rootofyourapp";

void Application_Start(object sender, EventArgs e){
    Dictionary<string,string> mapping = new Dictionary<string,string>();
    mapping[root+"/page"]=root+"/page.aspx";
    Application.Add("mapping",mapping);
}

void Application_BeginRequest(object sender, EventArgs e){
    HttpContext context = HttpContext.Current;
    string path = context.Request.Path;
    Dictionary<string,string> mapping =
        (Dictionary<string,string>)Application["mapping"];
    
    if(mapping.ContainsKey(path)){
        context.RewritePath(mapping[path]);
    }else{
        Response.AddHeader("Content-type","text/plain;charset=UTF-8");
        Response.Write("Invalid request: "+path+"\n\n");
        Response.End();
    }
}

And to forward all requests through to a single URI:

void Application_BeginRequest(object sender, EventArgs e){
    HttpContext.Current.RewritePath("~/Default.aspx");
}

Daily link icon Friday, April 14, 2006

  1. ViewState Decoder (2.1) by Fritz Onion. Also see this article by Paul Wilson (who apparently used to have a similar tool online that's no longer available) about ASP.NET's viewstate process (to read).

       (0) Tags: [ASP.NET]

Daily link icon Saturday, March 18, 2006

  1. ASP.NET 2.0 Training Center: Cross Training for Web Developers:

    This section of the ASP.NET 2.0 Training Center helps the PHP developer learn more about PHP, and also add to their skillset by mastering ASP.NET 2.0. In the coming weeks, you'll learn how to get up to speed with ASP.NET 2.0, and you'll find details about interoperability between PHP and ASP.NET 2.0.

    To help you, you'll also find a series of webcasts specifically created, from the ground up, by world-class experts and presenters to teach ASP.NET to PHP developers.

    Started reading the first article on the page and it's excellent so far.

       (0) Tags: [ASP.NET, PHP]

Daily link icon Monday, February 13, 2006

  1. I hate ASP.NET with a passion.

    I still think C# is a good language, and the .NET class libraries and VM are good stuff, but ASP.NET is an abortion.

       (56) Tags: [ASP.NET, C#, Programming]

Daily link icon Friday, February 10, 2006

Dump a db table in ASP.NET

One of the first things I do whenever I'm working with a new database technology (JDBC, ADO, ADO.NET, etc.) is write a table dumper to learn the API. It's also usually because I usually find myself without access to any handy db tools, so I have to write my own. Here's a dumper for ASP.NET/ADO.NET:

void DumpTable(System.Data.IDataReader reader){
    System.Data.DataTable fields = reader.GetSchemaTable();
    Response.Write("<table border='1'>");
    Response.Write("<tr>");
    foreach(System.Data.DataRow field in fields.Rows){
        Response.Write("<th>");
        Response.Write(HttpUtility.HtmlEncode(field["ColumnName"].ToString()));
        Response.Write("</th>");
    }
    Response.Write("</tr>");
    int numfields = reader.FieldCount;
    while(reader.Read()){
        Response.Write("<tr>");
        for(int i=0; i<numfields; i++){
            Response.Write("<td>");
            string s = reader[i].ToString();
            Response.Write(s.Length == 0 ? "&nbsp;" : HttpUtility.HtmlEncode(s));
            Response.Write("</td>");
        }
        Response.Write("</tr>");
    }
    Response.Write("</table>");
}

There may be a better way to do some of that (if there is, let me know). Just for reference, to connect and get a table dump (happens to be Oracle, but there's an equivalent for every db API in ADO.NET):

OracleConnection conn = new OracleConnection(
   "Data Source=dbtable;User Id=user;Password=pass"
); // wrapped to not break my layout
conn.Open();
OracleCommand cmd = new OracleCommand("SELECT * FROM table WHERE ROWNUM<100", conn);
OracleDataReader reader = cmd.ExecuteReader();

And of course, after dumping:

conn.Close();

That handy WHERE ROWNUM < n bit from here.

Update: For informational purposes, here's a similar utility function for PHP I have sitting around in my db library (modified slightly):

<?php
function printTable(&$table){
    if(!
$table){
        echo 
'Empty table';
        return;
    }
    echo 
'<table border="1">',"\n<tr>\n\t";
    foreach(
array_keys($table[0]) as $key)
        echo 
'<th>',htmlspecialchars($key),'</th>';

    foreach(
$table as $row){
        echo 
"\n</tr>\n<tr>\n\t";
        foreach(
$row as $data)
            echo 
'<td>',htmlspecialchars($data),'</td>';
    }
    echo 
"\n</tr>\n</table>\n\n";
}
?>

Daily link icon Tuesday, February 7, 2006

  1. SqlDataSource paging is lame:

    Note that the paging operation in the preceding example is being performed entirely by the GridView control over the DataView returned by SqlDataSource, which supports the ICollection interface. In this case, the GridView retrieves all of the data records from the data source, renders a subset of the rows, and then discards the remaining rows. This is sometimes called "UI paging" because the logic for paging is happening in the rendering layer of the GridView control. While convenient for paging over arbitrary collections, this is not necessarily the most efficient way to page over data. It is also possible to configure paging at the data source interface level, so that GridView requests only as many rows as it needs from the data source in order to render the current page. The SqlDataSource control does not support interface-level paging at this time.

       (0) Tags: [ASP.NET, Programming]
July 2008
SunMonTueWedThuFriSat
 12345
6789101112
13141516171819
20212223242526
2728293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 3 posts

Recent comments XML

Spider solitaire

To answer an earlier question, I am​almost certain every game can be​beat. ...

Jared: Jul 16, 2:20pm

I hate Norton Antivirus

I HATE NORTON ANTIVIRUS IT SUCKS I​GOT AVG IT ROX! AGES TO DELETE​NORTON AN...

wade: Jul 15, 1:44am

Girls, please don't get breast implants

Girls,

   Lots of guys enjoy​smaller breasts.  Several years ago​a well-...

j: Jul 13, 10:13am

Generated in about 0.159s.

(Used 10 db queries)

mobile phone