struck me funny….
Recursion /ree-ker’-zhon/: See Recursion.
struck me funny….
Recursion /ree-ker’-zhon/: See Recursion.
Just trying this tool for writing to this blog. Yeah, I know there have been tools in this space, i just hadn’t used them yet.
A colleague noted these two articles in her research and I thought this was good information to pass along. No sense in reiterating the content, just read these two articles (which reference each other). I’d still like to see at what point you “can” safely rely on the same thread (presumably once execution is inside the actual HttpHandler).
and
I can’t get into the exact details here, but suffice it to say, that when you stray out of the standard viewstate-sandbox (ie LoadPagestateFromPersistenceMediume & SavePageStateToPersistenceMedium), be very careful. Once you get viewstate out of that page and you consider users who use multiple browser tabs (yet with the same application session, or worse, new windows launched with Ctrl+N) there are a few subtle design considerations. This guy’s article provides one solution. If you also deal with multiple nodes (like a Web Farm), just persist to a shared location (Network share, NAS, whatever).
J
OK, i had a scenario where the database contained data with non-unique names, but we wanted to force the names to appear unique. For example, if you had “TheThing” and it was repeated 3 times, we’d want “TheThing(1)”, “TheThing(2)” and “TheThing(3)”. I had to do this all in Tsql since its in a SSRS report and that’s the clearest way to do this for the given situation.
So, I’m sure there are lots of other ways to do this (feel free to supply those via comments), but I used a temp table, and the tsql RANK() function to do it:
CREATE
TABLE #DuplicateNamesWorkAround(Id int, Name nvarchar(100),DuplicateExists bit,NameRank int)
INSERT INTO#DuplicateNamesWorkAround
SELECT t.id, t.Name,
(SELECT CASE
WHEN COUNT(*) >1 THEN 1 ELSE 0 END
FROM TableWithDups t
WHERE t.Name=t.Name) AS DuplicateExists,
— We’re creating a rank partition made up of the name with a hard-coded suffix.
— By doing so, we can get a rank thats unique per partition, and not across the
— entire resultset (since we want to append rank numbers to the name to give
— unique names).
RANK() OVER(PARTITION BY(
SELECT CASE WHEN COUNT(*) >1 THEN t.Name + ‘DUPLICATE’ ELSE t.Name END
FROM
TableWithDups t
WHERE t.Name=t.Name group by t.Name
UPDATE #DuplicateNamesWorkAround
SET Name=Name + ‘(‘ + CAST(NameRank AS VARCHAR(2)) + ‘)’ WHERE DuplicateExists=1
Nothing amazing, and perhaps there are better ways with counters and cursors, but this worked for me.
Ok, so we know this feature will become horribly abused and nobody’s going to know where the hell methods are defined. But, come on, you know you love this:
DropDownList cboProfiles;
int selectedValue= this.cboProfiles.SelectedValue.ToInt();
OR
int selectedValue= this.ViewState[“MyKey”].ToInt() ; Courtesy of these trivial extension methods: public static class TypeHelper
{
public static int ToInt(this string value)
{
return Convert.ToInt32(value);
}
public static int ToInt(this object value)
{
return Convert.ToInt32(value);
}
}
Admit it, your looking for a way for your next hit!J
<binding name=“ServiceBindingBasic“ sendTimeout=“00:1:00“ maxReceivedMessageSize=“10000000“>
<readerQuotas maxArrayLength=“10000000“ maxStringContentLength=“10000000“/>
<security mode=“TransportCredentialOnly“>
<transport clientCredentialType=“Windows“ />
</security>
</binding>
Then, after a few months, I started seeing this message on my [somewhat new] XP machine:
The HTTP request is unauthorized with client authentication scheme ‘Ntlm’. The authentication header received from the server was ‘Negotiate,NTLM’.
Yet, when these services were installed on Windows Server 2003 sp1, no issues. At the end of the day, the credentials were’nt flowing correctly from one machine to another, and when I finally found a small article that had one tidbit that worked, I got past this thing. I needed to set this on my dynamic proxy:
client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
So, if you ever see this error message, or a derivative of it, don’t go chasing down things like this crap until you’ve ensure your TokenImpersonationLevel meets whatever your requirements are.
I must admit, WCF security is a huge topic, and I certainly don’t lay claim to expertise in this area, so also consult others!
J
Yeah, I know I’m a bit late for the Ajax party (I was hung over from the WCF party), but I’m digging asp.net ajax big-time. I’m working through my 2nd book on the subject, and combined with lovely IDE intellsense sugar, the experience is downright fun!
J
ok, so the IDE is much slower when designing web forms, but other than that VS 2008, the 3.5 flavor of Asp.Net Ajax, and .net 3.5 in general rock the casbah big time.
For example, today I had to whip up a little code to serialize a small object graph to the client, so that I can allow users to interact with a couple UI controls, whose combined selection displays a result. It would be crazy to do a postback, and even silly to do an async ajax retrieval, as simply caching the object graph yields the very best user experience.
The new System.Runtime.Serialization.Json.DataContractContractJsonSerializer rocks. Combine that with a tiny extension method (see this article) and the serialization is easy. On the client-side, just use the Sys.Serialization.JavaScriptSerializer.deserialize(‘[your JSON here]’) and you are off and running. Very clean, very simple, very nice job Microsoft!
OH, by the way, i’m using the ajax slider, very slick as well!
J
I’d rant about this one, but this article and included code does so wonderfully.
This is no substitute for decoupling your code from things like HttpContext, but there are those times where its a near-dependency (ex. our legacy system uses the path to resolve certain client conditions)