Archive for the Delphi Prism 2010 Category

How to get Session Parameters in an ASP.NET ASMX service.

Monday, April 12th, 2010

Session parameters get used a lot in ASP.NET pages and they work pretty well, but when you try to use them in an ASMX web service, you get errors.  So, how do you get the session parameters?

It turns out that it is really simple.  Just add “EnableSession = true” to your WebMethod and it all works as expected.  For example:

[WebMethod (Description="Get a list of RMU GPS positions as JSON for the current custId.",
    EnableSession = true)]
public string GetSomeData()
{
    string  custId = "0";
    try
    {
        custId = Session["CustId"].ToString();
        return(GetSomeDataFromClientId( CustId );
    }
    catch (Exception ex)
    {
        handleException(ex, "GetGpsRmuCustListJSON");
        return(some failure message...);
    }
}

Tags: , , , ,

Delphi Prism 2010 Does Not Seem To Use Subdirectories

Friday, March 5th, 2010

When working on an ASP.NET website, I find it a lot easier if you put related sections in seperate subdirectories.  For example:

CSS and Javascript can be put in a directory with caching in order to speed up the page loads

Pages that are only available to certain roles (i.e. “Admin”) can be put in a seperate directory and then you set the web.config so that only that role can access the directory.  This helps to make it really clear who the page is ment for.

While attempting to port a site from Delphi RAD 2007 to Delphi Prism 2010, I was amazed that it would not let me do this.  I even opened a site in Visual Web Developer 2008 (the Microsoft compeditor that Prism basically uses as the IDE) to check if it was a Microsoft issue.  Not only did the Microsoft Web Developer 2008 allow it, but when I went to create a code file, it suggested putting it into app_code and offered to move it there for me (but did not force me to if I didn’t want to).

In comparison, in Delphi Prism 2010, I opened {project}\css\proj.css.  Instead of allowing me to use the file where it was, Prism created a brand new file {project}\proj.css and added that to the project.  To add to the confusion, it left the old file {project}\css\proj.css.  Now I have two copies of proj.css.  I tried it with several different files and kept having this issue.

Not only is this annoying, I find that this really makes a larger site a lot harder to maintain.

Tags: , ,