blog.x-e.ro / dotnet: page 1 of 5

RFC822 compliant dates for rss feeds

php :: in php and asp.net

with the advent of web-syndication, a few different feed protocols have evolved (rss and atom being the most popular). because of their growth in popularity the protocol to create a feed has become more stringent. luckily we have validators who help us keep our feeds on the right track. one of these guidelines is RFC822 compliant dates. these dates look like Sat, 14 Jul 2007 18:40:26 -0400. formatting your data to be compliant with this standard can be challenging, so i have written some code to help you along... 

Creating a RFC822 compliant date in php is a snap...

$rssDate = date("r");

in asp.net this is a bit more tricky. microsoft doesn't have a native RFC822 date format, so we are going to have to convert our dateTime.now() into that format...

Read: RFC822 compliant dates for rss feeds »

asp.net random number generator

c-sharp :: the central randomizer

here is my asp.net randomizer class based on the c R250/512 shift-register sequence random number generator, by kirkpatrick and stoll and published (j. computational physics, vol 40, pp. 517-526) with an added a pseudo-random class redefinition and buffer overflow protection.

example usage:

randomizer x = new randomizer();
int num = x.random();

Read: asp.net random number generator »

dotnet sendmail

c-sharp :: sending email with c#

sending email is a snap with asp.net 2.0, this simple function sends an email to the specified name and email you pass to the function. with a little database integration this can be recalled in almost infinite recursion, and will not be tagged as spam because it sends individual emails, not a bulk message to many users. for fastest delivery times specify the direct path to your mail server (see line #18), and setup your mail server to not scan outgoing  webserver mail for spam. *edit* i now recant that statement. true, pure execution times will be faster but at the sake of ignorance. i would rather have the slightly increased send time and the knowledge that my code has not be hijacked and sending spam. 

example usage:

sendmsg("xero", "x@xero.owns.us");

Read: dotnet sendmail »

asp.net pure code database connection

c-sharp :: three different ways

visual studio 2005 has a tool for connecting to a database called a "sqlDataSource". while this tool works, i find myself wanting to create the connection and build or execute stored procedures within my own C# code. this tutorial will show you how to connect to a sql database 3 different ways in asp.net

the first thing is creating a connection with your database. if you understand how connection strings are built, write your own other wise will can use the visual studio database tool to do that for us.

configure database

Read: asp.net pure code database connection »

post and querystring vars in dotnet

c-sharp :: asp.net c#

here's a nice little snip of c# code. this is meant to be used in an asp.net web application. the following code will return either a querystring variable or a post variable, it tries both and finds the valid one.

public string RequestParam(string paramname)
{
    string result = string.Empty;
    if (Context.Request.Form.Count != 0)
    {
        result = Convert.ToString(Context.Request.Form[paramname]);
    }
    else if (Context.Request.QueryString.Count != 0)
    {
        result = Convert.ToString(Context.Request.QueryString[paramname]);
    }
    return (result == null) ? string.Empty : result.Trim();
}

Read: post and querystring vars in dotnet »

loading...

loading...