CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Peter's Gekko

public Blog MyNotepad : Imho { }

May 2004 - Posts

  • SmartNavigation and Redirect (not !) again

    Some things just happen twice. I had been battling smart-navigation before. Trying to redirect from code on a page with smart-navigation switched on can lead to blank browser screens. The solution was to set smart navigation to false first before making the redirect. In some recent code I had forgotten about this and back were the troubles.

    The bad thing is that it doesn't show up until the actuel user hits it. No problems with the code on my XP localhost. No problems when the sa (Running a localhost account ....) tried the app on the W2K production server. Blank screens when the domain user hits the page.

    The easy way out is the smartnavigation tag in the aspx file.

    <%@Page language="c#" Codebehind="default.aspx.cs" AutoEventWireup="false" Inherits="ProjektManager.Projekten" smartNavigation="True"%>

    The sa can update that with notepad, asp.net will recompile the page. And the user can work again. Without smartnavigation on that particular page. Things could be worse :>

    Peter

     

  • MSDN subscription discs

    Finally tidied up my office. Cleared out a couple of old MSDN subscriptions. A two year old CD european subscription. The Greek Windows 98 brotherly next to the Turkish Windows 2000. Both never been used. I'm still looking for something to do with these piles of outdated discs.

    These days I have a DVD subscription. One set of about 12 disks covers all US versions. And another set all european languages, including Dutch. I do use the US disks a lot, the localized seldom. May I suggest a new subscription type : Broadband. : Discs US-UK only, other locales downloadable.

    Peter

  • WinInfo newsletter no longer considered spam

    For several months I had been digging through my spam mailbox to get WinInfo update and related newsletters. It took some effort, I even built some tools to automate the process, but the content was allways worth it. Since last friday they are back where they belong. They made it out of the blacklist. Congratulations. Newsletters still recommended.

    Peter

  • Mailto links

    Recently my neighbour Warnar blogged a little on sending mail from an app. He explained how to use the smtpserver on the webserver. Recently I needed some mail functionality on the client machine. A web-page should start an email message to be sent by Outlook (Express) or whatever other client used.

    This is a snap using mailto links. Clicking a mailtolink will fire up the emailclient, the browser will take care of the details. The mailto protocol supports several parameters, see here for more details. Take this link:

    mailto:Peter@Gekko-Software.nl?subject=From the weblog&body=Your comments here

    Click it to mail me (Spam filter is active). The link is typed directly into the navigateUrl property of a hyperlink. To customize it you use databinding.

    My app had to generate messages with a body which contained a new link to some web page. At first sight this code would generate that :

    result = string.Format("mailto:{0}?subject={1}&body={2}", email, subject, body);

    It did not work, as the link in the body often contains an &-character. This character separates parameters of the mailto-link. The result would be that anything after the & will not be in the body. Another thing to watch is that a link cannot return line-feeds. And it does not like “'s either. As I did not find anything in the framework which will creat a valid link out of just any text I solved it by applying several Replace calls to the string.

    string quote = new string('"', 1);
    body = mail.Body.Replace(System.Environment.NewLine, "%0A").Replace(quote, "%22").Replace("&", "%26");

    Have I overlooked something in the framework ? Is this a full clean ?

    The result is that my web pages now contain fully functional mailto's. Customer loves it.

    Peter

     

  • DotNed and the SDGN

    DotNEd will meet again the 27th of may. Interesting part of the evening will be a presentation by the SDGN, an other Dutch user group with a discussion on “what can the community do for you ?”. A lot ! And what can you do for the community ?

    Peter

  • MSDN briefings, why developpers do not like security issues ?

    Today I visited the MSDN briefings. Having coded to much (looking for the crtl (shift) B(reak) on the alarm clock in the morning :>) it was time for a day out. Theme of the day was security. The sessions were quite nice, one by fellow blogger Alex Thissen. But at the end of the day a little unrest came over me. No sexy code, security in .NET is a question of two simple interfaces, setting some attributes and lots and lots of configuration files. A day which gave me a lot of insight, but the real work is not that attractive to do. I'll be happy again to write “real” code.

    Peter

  • Lofar supercomuting and Linux

    Yesterday I blogged a little on the many things interesting ICT project running over here. One of them was the Lofar radio telescope, its heart being a giant supercomputer. Important parts of the project are the network and the computer, but not storage. The main thing the supercomputer will do is act as a giant DSP, in realtime it will filter information out of the gigantic amounts of data coming in.

    James suggested C# being a good choice to implement the software. Would be interesting. The supercomputer to be used is an IBM-Blue gene, supplied by the IBM R&D department. It's an array of thousands of Power PC processesors running under ... Linux. Ok, let's install Mono. The nature of of the software, processing a continious stream, is also quite different from the request/response message oriented software most of us are using .net for. I havn't a doubt .net could do it, but I do not think they will do it that way.

    Lofar's resulting information will be available to the public on the internet as well. I don't know yet in what format. Streaming video images of the sky (at day and night), webservices ? Stay tuned.

    Peter

  • Lofar, RoboChallenge, GN-IX : the North has it all

    Just over 3 years ago we moved to the north of the Netherlands. To most fellow countryman we might just as well have moved to the moon. It's a two hour drive to get from here to Amsterdam it takes twice as long to get from there to here (according to “western-ers”). The quality of living here is a secret we rather keep to ourselves, the amount of amazing ICT technology we have deserves some more attention.

    Yesterday (may 12th) I visited the first meeting of the ICT platform Groningen. A quite diverse day. The keynote was on the Lofar project. The Netherlands already have (one of) the finest composite radio telescopes (astronomy) in the world, the lofar project is about creating a new one with a radius of over 400 kilometers, centered around Dwingelo. This project involves

    • Installing 10.000's of sensor devices
    • Connecting all these sensors in a heterogenous network
    • Centralized online processing of all incoming data in Groningen

    The amount of data, the bandwith to transport it and power required to process it is gigantic. The spin-off of all these projects as well. We allready have a very high quality internet connection thanks to the transatlantic cable landing here (another one is the Amsterdam internet exchange), lofar's infrastructure will spread broadband over the country. Further R&D promises devlopment in astronomy, agriculture, geophysics, super-computing and so on. One of the best things of the project is that it manages to cross boundaries in the world of science.

    The meeting had sessions on all the nice things you can do with broadband internet. Good, but nothing new to a dnj-reader. The top attraction of the day was a robot challenge where contesting devices were hunting plastic balls. Allways great fun. Two out of nine competitors used .NET for the controlling software. One of them won the prize for best overall design, the other one didn't run due to mechanical faillure.

     

    Yes, it runs .NET

    Peter

  • Good drive !

    At the moment the (Dutch) market is flooded with bargains for external (200-250 Gb) Maxtor hard drives. With a price of just over an euro a gig (excluding VAT) I couldn't resist. After a couple of weeks I'm still so satisfied with it that I just have to blog about it. The drive is fast, the connectors (USB 2 and firewire) are fast and, most important of all, it is silent. You can't hear it but when you touch it you will feel a vibration, something like the vibration of a cycle chain when acellerating. This vibration could cause some noise, but some very good rubbers are included. All  accesories coming with are abundant and of a very good quaility

    The USB and firewire cables look like they are certified for 380kV. The power adapter includes two cords, the dull european one and the gigantic Britsh one. The adapter side of the cords is universal so now I can take my notebook to the UK as well. The adapter itself looks small but has a built in power buffer, when you pull the plug it gives the drive the opportunity to go to standy.

    Really recomended.

    Peter

  • An optional parameter in a select query

    SqlDataAdapters are great. They provide a nice and maintanable way to get data from the database in and out of typed datasets. The drawback is that you need a new adapter for every new query. Usualy you need at least two select queries to read data, one to get an ordered list of rows and one to get a single (details) row. And often you need even more, one for all, one for a selection and one for a single row. This pattern is better recognized in VS 2005 which will generate overloaded methods to return selected data. But right now I had to add the possibility to select data in an existing 2003 app.

    I could use a dataview but this would involve loading all data from the database before selecting. Instead of creating new adapters for all new queries I slightly modified my existring queries and the code using them. The Select sql went from

    SELECT idMedewerker, MedewerkerNaam, LoginNaam, Email, Beheerder FROM Medewerkers
    ORDER BY MedewerkerNaam

    to

    SELECT idMedewerker, MedewerkerNaam, LoginNaam, Email, Beheerder FROM Medewerkers
    WHERE (Vestiging = @vestiging) OR (@vestiging IS NULL)
    ORDER BY MedewerkerNaam

    The WHERE clause uses a parameter (@vestiging) but will not check database values against it when that parameter is null. The decision to select is brought to the code

    if (select)
       mySqladapter.SelectCommand.Parameters["@vestiging"
    ].Value = vestiging;
    else
       mySqladapter.SelectCommand.Parameters["@vestiging"].Value = DBNull.Value;

    No rocket science but it works (on my database server). The good thing is that I do not have to create (and maintain !) new adapters and the dataset is unchanged so it will not break code. It has a little overhead on the sqlServer side, but I consider sqlServer samrt enough for the price to be neglectable.

    Peter

  • Who is that requesting my web page ?

    A quick how to on identifying an user from code. Nothing special, but it works on my (customer's) machine.

    The default in ASP.NET is that any anonymous user browsing your site is allowed access to all pages. To change that you modify web.config. How to do that is documented in the comments of the web.config file VS generates. To disable anonymous access change the default

    <authorization>
       <allow users="*" /> <!-- Allow all users --
    >
    </authorization>

    to

    <authorization>
       <deny users="?"></deny
    >
    </authorization>

    The next step is set up the way the user will be authenticated, this is also set in the web.config. This is the default

    <authentication mode="Windows" />

    Now asp.net will check the identity of the user to the Windows users known on the machine the web server is running. When you run your apps using localhost your current Windows login will work fine. But when you access the webserver from a remote client you browser will pop up a dialog requesting an userid, pwd combination which is known on the server. The nice thing is that asp.net will keep this info the whole session, browsing from page to page will not pop up a new login dialog.

    MyUser = context.User.Identity;

    The only problem with this is that you do need the context of the web form. A database component, where there are many reasons to know who is using the data, there is no context. To solve that the HttpContext class has a static (shared) memeber which will return the current context from wherever you are

    MyUser = System.Web.HttpContext.Current.User.Identity;

    There is an enormous lot more to be said about user identification. None of it is rocket science, just a matter of finding the right classes and members in the framework. I hope this little story has given a first direction.

    Peter

  • Do more with less (time)

    Spent last week working on several projects. Had to do several weeks of work in one week. Quite a stress test on me and VS (2003). We all more or less survived. Some reflections :

    • I need a portal. Integrating several web apps by hand makes you feel like reinventing a wheel allready rolling.
    • I need an O-R mapper or other tool to take one step away from the underlying databases. SqlDataAdapters and Components are great but you end up with a monster application. Thank goodness it's a gentle whale, enormous but with friendly behaviour.
    • Crystal Reports look nice but the report designer integrated in VS can be annoying. You cannot move a subreport from one section to the other, you have to recreate the whole subreport... And sometimes clicking something blows away VS. Without warning.
    • VS.NET is really nice. Best feature I discovered is moving a webform from one application to the other. Which is a matter of drag and drop in the solution explorer. In the code you only have to update the namespace by hand.
    • Trying to install multiple web-applications from one msi can be good way to make Windows installer produce very erratic messages.

    Now it's time to read some blogs.

    Peter

  • Preview data in Visual studio to a (un)-typed dataset

    The last days I've been ploughing through loads and loads of code, including lots and lots of database queries. I totally agree with Brendan, all query results should end up in typed datasets. But in an early stage of the development proces, still figuring out what data I really need, that dataset isn't available yet. When previewing data in VS (right click your data-adapter) you can preview in an untyped dataset.

    Discovered this feature only recently, it is well hidden. When you scroll the target dataset dropdown up the untyped dataset pops up. Very well hidden..

    <Update>You can also do it the sloppy way, just hit fill dataset whatever target schema is selected. The dialog will create new entries for every table it found and display all data it found in that table.</update>

    Peter

More Posts