July 2003 Entries
This is
an excellent article - I think many of us (certainly I have) have on occasion felt
like the article describes.
Read on
Robert McLaws blog
that some Whidbey information (next version of Visual Studio and .NET) has been
made
public . I can't wait for this to come out - it really is a massive improvement
- I also can't wait to be able to talk about it and use it on real sites :-)
This is also pretty nice
:-P
This is a wonderful project, providing a
Rich Text Editor for the ASP.NET community. If you can afford to contribute to this
project, please do (I plan to very soon :-P). Essentially it provides an embedded
HTML editor which you can use in any ASP.NET (oh, and ASP 3.0) project. Even if you
don't plan to use it, have a look at the sourcecode - as an example of how to create
a ServerControl its' pretty cool...
Cool new Blog -
http://xplsv.com/blogs/devdiary/ by
David Notario
Here's an
article on
4Guysfromrolla about
the
DAAB (don't
know what that is, click on the link!
This is a really useful resource http://www.i18nguy.com/markup/metatags.html .
On cachig and Meta tags in general.
Just noticed over at .NET Weblogs,
Paschal links
to
Jim Byrne with a
collection of articles on web design and accessibility.
Noticed this on
.NET weblogs, a post about
a
bug in the DAAB
V2
I've recently been following a thread on accessibility in ASP.NET - now this is a pretty important subject for any web developer. It is
illegal not to make your site accessible and can lead to a hefty fine!
At the moment, ASP.NET pretty much sucks for accessibility - which means ASP.NET pretty much sucks for doing much work for the government / large companies who care (i.e., have to care) about accessibility (no, plain text versions don't qualify - you're still technically discriminating against the user who can't use all the flashy features).
If anyone has any links to publicly available information(i.e., not covered by an NDA) on accessibility in current and future versions of ASP.NET.
I'm working...hmm...thought I'd mention a very odd bug I came across yesterday at
work - which had me puzzled for about a day and a half...
I had written an application (the Portal I've mentioned before - The
Education Community), which uses the Data
Access Application Block to provide the DAL - which I highly recommend. Anyway,
this has always been faultless on every platform I've tried it on. The code is below...
string user = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
string exceptionStr=exception.ToString() + exception.StackTrace;
SqlParameter[] sqlParams = new SqlParameter[4]; SqlParameter
prmUser = new SqlParameter("@user",SqlDbType.VarChar,500);
prmUser.Value = user;
SqlParameter prmMessage = new SqlParameter("@exceptionMessage",
SqlDbType.VarChar, 2000);
prmMessage.Value = exception.Message;
SqlParameter prmExStr = new SqlParameter("@exception",SqlDbType.Text);
prmExStr.Value = exceptionStr;
SqlParameter prmPortalId = new SqlParameter("@portalId",SqlDbType.SmallInt);
prmPortalId.Value = 0; sqlParams[0] = prmUser;
sqlParams[1] = prmMessage;
sqlParams[2] = prmExStr;
sqlParams[3] = prmPortalId;
/*SqlHelperParameterCache.GetSpParameterSet(_connectionString,"pr_Admin_InsertError"); sqlParams[0].Value
= user; sqlParams[1].Value = exception.Message; sqlParams[2].Value
= exceptionStr; //sqlParams[2].Value = "Test String"; sqlParams[3].Value
= ((PortalSettings)HttpContext.Current.Items["PortalSettings"]).PortalId;*/
SqlHelper.ExecuteNonQuery(_connectionString,CommandType.StoredProcedure,"pr_Admin_InsertError",sqlParams);
I use a method it provides called SqlHelperParameterCache.GetSpParameters (commented
out in the code above) - this basically just populates an array of SqlParameters with
the parameters returned from the DB - saves a bit of coding and makes the app easier
to update as the SPs change - nice!
Anyway, this has worked faultlessly, fast, efficient all of that! Until that is, I
tried to deploy to our test environment on Thursday - I kept getting various errors,
Severe Error and General Network error back from SQL Server 2000 when I tried to run
the commented code above. Well, the version of .NET on that machine was 1.0.3705.352
- a version I'd never seen and can't get - but I assumed, .NET 1.0 was all pretty
much the same, maybe a few bugfixes but thats' about it!
Umm...wrong, turns out this version has a major issue when you try to get the parameters
back from an SP when the SP expects a 'text' type field - it just gets it wrong somehow
- and causes this awful, puzzling error. Solution, explicitly declare the field types
for the parameters if your SP contains a 'text' field (only one I've tried it for,
may affect more 'binary' types).
Anyway, fixed now - but I do recommend you upgrade to 1.1 - which also has a fantastic
thing I discovered from some blokes blog at the ASP.NET
weblogs simple but saves a bit of typing, seems that DropDownList (I expect
RadioButtonList has it too, but not tried it!) that is a SelectedValue property -
how cool is that - well not that cool, but its' better than doing the old ddl.SelectedItem.Value...bit
shorter...
Very useful...http://www.manoli.net/csharpformat/
ASP.NET has a problem with file downloads...basically if you use Response.WriteFile(fileName),
the entire file is buffered in memory before its' downloaded - this is NOT good for
scalability. To get round that proble, here's some code which could be used for file
download - it looks the file download, only downloading chunks at a time. Also checks
that the client is connected before sending the next chunk...
private void DownloadFile(Guid itemId)
{
//Where to start in the file
long startPos = 0;
//How big a chunk to download in each iteration
long chunkSize = 20480;
//Use the id to retreive the resource files details
using(SqlDataReader reader=SqlExtra.ExecuteReader("GetResource", itemId))
{
try
{
if(reader.Read())
{
//Get the file details we need to save a copy to the client
string fileExtension=reader["FileTypeExtension"].ToString();
string fileNameClient=reader["FileName"].ToString();
string fileNameServer=Server.MapPath(string.Format(@"Uploads/{0}{1}", itemId.ToString(), fileExtension));
FileInfo file=new FileInfo(fileNameServer);
//Only proceed with the download if the file physically exists
if (file.Exists)
{
//Setup the Response object to allow file downloads
Response.Clear();
Response.ContentType = "application/octet-stream";
//Attach the file to the response stream.
Response.AddHeader("Content-Disposition", string.Format("{0}{1}", "attachment; filename=", fileNameClient));
Response.AddHeader("Content-Length",file.Length.ToString());
long fileSize = file.Length;
try
{
while(startPos < file.Length)
{
if(Response.IsClientConnected)
{
//write the file to the client
if(startPos + chunkSize > fileSize)
{
chunkSize = fileSize - startPos;
}
Response.WriteFile(fileNameServer,startPos,chunkSize);
Response.Flush();
startPos += chunkSize;
}
else
{
break;
}
}
}
catch(Exception ex)
{
ExceptionManager.Publish(ex);
}
Response.End();
}
else
{
//display an error message
StatusMessage.Text=fileNameClient;
}
}
}
catch(Exception ex)
{
if(ex.GetType() != typeof(System.Threading.ThreadAbortException))
{
ExceptionManager.Publish(ex);
}
}
}
}
Hope you find it useful... sorry about the formatting...seems this page isn't very
flexible...hmm...
I'm currently generating an update procedure for an installed site - this involves
generating a change script for the DB to make the deployed one the same as the new,
modified one (yes, I know you should create change scripts as you go along...well
I was on holiday for 2 weeks and the other developer on the project didn't). Anyway,
if you have to do this on a reasonably large SQL Server 2000 Db, I can't recommend
AdeptSQL
Diff highly enough, I've tried 4 (count them, FOUR!) other products which
claim to do this, LockwoodTech SqlDiff and Redgate Sql Compare being the two I can
recall right now, and they failed miserably to do the updates I required - SqlDiff
failed entirely with some odd error, Sql Compare generated a script which would never
work oh, and they were both slow as hell! AdeptSQL Diff was VERY fast in comparison,
had the best UI and actually worked...which is nice...
Well, its' back in its' box, waiting to get sent back. The phone just plain sucks
- OK, the have this swish new high-speed network - does it support internet access...umm...nope.
The battery literally lasts like 4 hours, the UI is just plain the worst I have ever
seen on anything anwhere. It looks like a bargain (£35 for 750 minutes of cross-network
calls!), but you'll spend what you save on an osteopath, these things are huge! So
I'm on the market for a new phone, small as possible, bluetooth and GPRS but not on
Orange (they block the VPN ports...idiots!).
Hmm...got a new swish 3G mobile phone, the NEC
e606, got a pretty good deal - works out cheaper than my old phone with a GPRS
package - but with 10 times tha bandwidth and no restrictions on VPN ports which my
old orange phone had...Have to say though, that the UI is the most unfriendly one
I've ever used - for instance, the backlight settings are in the Java menu...???
Anyone else got experience of these things / have any tips...email me...
As I've written about a hundred times now. I'm currently rebuilding this site - don't stop reading, I really am this time!
So, I'm in the process of defining an architecture - rebuilding the site is more about my playing with some new technologies rather than actually making a site thats' for anything. The architecture I choose will have many of the features I'd expect to see in ASP.NET 2.0 - with a view to converting once I get the bits.
The way it is currently going is to use a version of MasterPages , maybe taking a few pointers from Paul Wilsons articles on the subject. In addition I want to have some sort of MVC type implementation, where I can control the flow and navigational logic from a central location - there's an approach I've used before in Java where the Controller is responsible for filling the page Context with the information which the page needs to render, the page then just has to access Context to populate itself, might see if this is easy in ASP.NET.
Of course, I'm going to be heavily using the MS Application Blocks - I can't emphasise enough how fantastic these things are when building applications!
One thing I really dislike about the current BlogX - the blogging engine currently powering this site - is that it doesn't use SQL Server- this essentially means my information is stored on the server in plain XML - it's hard to index (no search!), if some other format comes along, it'll mean writing a hideous XSLT to do the transform and I can't load balance the site (OK, not a problem any time soon, but the Architect in me objects). Plan will be to replace BlogX with another engine (with a better architecture), this will be based on SQL Server, have built in support for encryption and compression -I hate the fact that right now, big old chunks of unencrypted XML contain the config settings for my site and regularly fly through the ether - this is NOT secure in the slightest. In addition, front-end caching (even more necessary with the shift to SQL Server) - I may even have a look at caching each blog entry as an entity and then just assembling them as the page renders...hmm...
As we all know, C# lacks an IsNumeric method,
this
article at AspAlliance looks at various methods of doing this and benchmarks them
to find the quickest...
This discussion on
Slashdot has
finally made my mind up. I have been a reader of Slashdot for a number of years,
I believe I started reading it in the first month it existed. I'm even one of the
smallish number of people who subscribes. The eternal Microsoft bashing whey now indulge
in is getting very boring - when is the last time anyone wrote a story not actively
criticising Microsoft on that site. I have in the past worked with Solaris and have
been heavily into J2EE coding, I have nothing against these technologies, I don't
use them every day now because, simply I'm more productive in .NET / Windows.
So the eternal idiocy of Slashdot - which is owned by the OSDN...a distinctly anti-Microsoft
organisation, please don't believe they're subjective. Has finally pushed me over
the edge, goodbye Slashdot, I don't need to get wound up over these dumb stories any
more.
There really are some! Found at Joel
On Software...
I especiallt love this one...
"Computers are high-speed idiots, programmed by low-speed idiots"
Just noticed over at Devhawk that
V2 of the DataAccessApplicationBlock has been released...
Just When You Thought It Was Safe...
The prescriptive guidance is coming fast and furious now. The User
Interface Process Application Block is a framework for abstracting the control
flow and state management out of the user interface layer. The Configuration
Management Application Block is a solution to manage configuration data across
your applications. And the Updater
Application Block provides a mechanism to build the ability to update directly
into your application.
Also, from ScottW, I discovered that the Data
Access Application Block v2 shipped
last Friday. Hasn't shown up on MSDN
yet.
I've written about these before, but if you are planning to develop any sort of ASP.NET
/ other .NET based app, you can save yourself a whole heap of time an aggrovation
by having a look at the .NET application blocks, for instance the Data
Access Application Block provides a very useful (and quick...and free source)
satatring point for any DAL.
The Exception
Management block provides a really useful, extensible interface for reporting
any exceptions in your apps...
A couple of new blocks have also appeared recently, of which the most useful in ASP.NET
apps would seem to the the Configuration
Management block. Again, this provides a simple, extensible way to handle configuration
within your app (come on, how many times have you needed a way to have a writable
config file...well, now you've got it!).
Along with these three, there's another 5 blocks, (click on any of the links above
and you'll see links to the others). The Aggregation Block provides a very nice way
to composite information from multiple sources and to provide a consistent interface
to that information, Asynchronous Invocation...does what it says. Caching Application
Block - a consistent way to handle cachining in any .NET app (especially things like
web services!). Last but not least there's the Updater (guess what that does :-P))
and the UI Process block. Now this one is very interesting (and very new!)...here's
the summary:
The User Interface Process Application Block provides a simple yet extensible framework
for developing user interface processes. It is designed to abstract the control flow
and state management out of the user interface layer into a user interface process
layer. This enables you to write generic code for the control flow and state management
of different types of applications (for example, Web applications and Windows-based
applications) and helps you write applications that manage users' tasks in complex
scenarios (for example, suspending and resuming stateful tasks). This leads to simpler
development and maintenance of complex applications. The User Interface Process Application
Block can easily be used as a building block in your own .NET application.
How cool is that...almost Struts for
.NET (sorry, obscure Java reference...struts is very cool!
Well, had a very restful holiday...back to work now though. In typical Scottish
fashion (well Edinburgh), it's raining outside. So, plans for the next few days include
learning more about mobile controls...extending my winforms knowledge and generally
working on some projects which interest me.
Unfortunately it also looks like I'm going to have to rebuild my home dev machine...which
is a bit of a pain (new motherboard I had to install seems to have caused XP some
problems...)
Can anyone point me to some decent resources for Mobile App developement with the
Compact Framework???
I'm currently on holiday - hence no new entries. Be back in a few days - lots of cool
stuff on Pocket PC programming with the Compact Framework coming up :-)