Life, Surf, Code and everything in between
White Papers | Free Tools | Products | Message Board | News |

Last 24 Comments

re: ASP.NET gets no Respect
Today @ 11:22 pm | by Whitesites

Rick,
Yes cost is an issue with MSFT products ( especially SQL server ). Thus it has spawned a generation of guys like me who prefer to write asp.net code in dreamweaver, and use MySQL for the database. I am just not a fan of visual studio, or making pre compiled DLLs. I would rather keep the source code on the server, so I could remote in and patch things up if I was desperate from my cell phone.

When a programmer starts out, they don't even know enough to know what they don't know. They are scared to spend the money on software only later to find they don't have what it takes to write code for a living.
re: ASP.NET gets no Respect
Today @ 2:06 pm | by Rick Strahl

@Vladimir - I agree on that much of what is shown in the 'basic' examples and documentation encourages bad practices, especially when it comes to data driven applications. As i mentioned in the article that the biggest hurdle to ASP.NET is indeed the .NET framework's size/breadth that is quite overwhelming when getting started.

If we're talking about ASP.NET in general and alternatives to Web Forms (say MVC) though we have to say that those same rules will apply regardless. Data access, and general programming code/utilities etc. always have to be learned before you can do any thing really productive.

But I'd also argue that using ASP (classic) or other scripting languages aren't exactly what I would call good design. Creating maintainable applications using scripting code is very difficult and requires a lot of discipline.

My point is simply that if you apply discipline to Web Forms the same functionality is available as in scripting environments. For example, I have NEVER used any of the ASP.NET DataSource controls in production code. Heck I don't even use them in demos. They are awfully designed and add inflexibility. There's nothing stopping you from writing data access code manually with code and binding data manually ( as you would have to with scripting ) or - which is the approach I use - to use my own data binder that I've built that fits my needs exactly.

I can't overstate the latter case because it's maybe the main reason I really like Web Forms: It's an extensible object model and not just a dumb view container, and you as the developer have control over the page rendering process in ways that is simply not possible in a scripting environment.

But yes believe me - I see your point. About the complexity, about the bad practices the Web Forms guides you into out of the box. Totally get that and I think that IS why Web Forms gets such a bad rap. It just bugs me because most of these issues are only true if you let yourself be pidgeon holed by the default Web Forms model, but this is not the way it has to be.

I don't know how to change that either though. New users will not want to use more manual approaches to development when high level tools like DataSource controls exist. Especially if that's what's advertised out of the box.

This is maybe why MVC is really hitting a nerve - it's not a half way solution but a complete break with the old architecture and going from scratch with the low level approach. I'm just not so sure that this model goes too far into the other direction.
re: ASP.NET gets no Respect
Today @ 1:04 pm | by Vladimir Kelman

OK, Rick. I'm not very experienced in ASP.NET, I must admit it. But overall, I program web pages for a long time. And what books and MS documentation teach on ASP seems often seems to be a bad design. And, as opposed to simple things like ASP or, better, PHP, ASP.NET is so big, that it is hard to find a good approach by yourself.
I understand that there are pluses like the ability to use controls and data binding. However, how do you resolve a simple situation described in http://www.strong-point.com/Blogs/tabid/87/EntryID/9/Default.aspx? You have an "edit" page and a Save button to save changes. It is naturally using POST operation and posts to the same page - by default. Then you click Back button - and it displays that "Web page has expired" message.
It would be bad idea to allow page cache, because values were changed as a result of POST operation (perhaps - saved). In ASP or PHP I always POSTed to another page which didn't have HTML, saved data there and then redirected back. Yes, you can use cross page postback(like http://www.odetocode.com/Articles/421.aspx) it it looks crazy and overcomplicated.

I found that in many cases doing things "manually" on a lower level is actually simpler. ObjectDataSource is a great thing, isn't it? But why does it require my business object to have a parameterless constructor and define set {} for properties which supposed to be get {} only? UI i snot supposed to dictate my BO design. Yes, I know I can use ObjectCreating event http://weblogs.asp.net/srkirkland/archive/2007/10/10/using-bll-objects-with-parameterized-constructors-in-an-objectdatasource.aspx, but it seems that on Update ODS requires parameterless constructors and set {} anyway...

All looks great on a surface, but as soon as one tries to do something meaningful, strange things immediately reveal themselves, like no one before (or no book authors) did a real-life projects in ASP.NET.
re: ASP.NET gets no Respect
Today @ 11:41 am | by Rick Strahl

@Vladimir - Breaking the back button? Huh? How's that? ASP.NET is no different here than any other Web platform. ASP.NET is not the only mechanism that uses postback to the same page which is a reasonable practice for data entry operations and which I've used way before I ever touched ASP.NET.

A lot of complaints I see against ASP.NET Web Forms are leveled out of ignorance. Not understanding the platform and not investigating far enough to understand what you can do (relatively easily) to bend Web Forms to work in a more lean way. I've been doing this from day one with Web Forms precisely because I came from a more traditional Web development background where everything was done by hand and some constructs in Web Forms (like postback code from links on a all controls and ViewState for everything) have always felt unnecessary, but also easily bypassable.

A lot of people forget that there are also many very useful things about Web forms like the Postback data management and the ability to have a reusable control model. A page that can be controlled and allows building high level controls that act on the page - for example I would not want to live without my custom Databinder control that handles all aspects of binding data to controls without having to worry about string to type and vice versa conversions or manually tracking each field bound. These sort of things are not easily duplicateable in other tools because there's no structure the UI.

@Mark - sorry what you're railing against sounds like sour grapes to me. When's the last time you've seen a 50 developer FoxPro shop? In 1990 maybe? I think you also sound like you're comparing desktop development rather than Web development which is a whole different beast. Web development always has complexity regardless of which tool you use. A lot of people using ASP.NET are lulled into thinking that it should be super easy because when you start out with ASP.NET it just feels that way. Once you work more with it you realize that Web development is complex and you can't completely get away from the abstraction and you still need to be able to apply Web principles to layout and even the state management.

My point is that Web Forms can be made to run lean and mean if you put a little effort into understanding the underlying Web platform as well as Web Forms. The same effort that gets thrown into learning something like MVC which is not without its complexities - especially when it comes to building more than simple user interfaces that manage multiple pieces on a single Web page.
re: ASP.NET gets no Respect
Today @ 6:31 am | by Vladimir Kelman

I think that a major issue with a standard Web Form / POSTBACK / server-side controls paradign of ASP.NET is that it broke BACK button. An issue is well described in this post http://www.strong-point.com/Blogs/tabid/87/EntryID/9/Default.aspx, so I won't repeat.
I programmed for many years in classic ASP and in PHP and always used a clean PRG (Post-Redirect-GET) approach, although I didn't know the term and re-invented that approach by myself.
http://www.strong-point.com/Blogs/tabid/87/EntryID/8/Default.aspx
http://www.theserverside.com/tt/articles/article.tss?l=RedirectAfterPost
http://www.theserverside.com/tt/articles/article.tss?l=RedirectAfterPost2

I know that we could use some tricks with cache.
I know that Ajax (Update panel, etc.) kind of solves this problem at the expense or more complicated model, difficulties with debugging, and maintaining History.
As far as I understand, MVC (ASP.NET MVC) is supposed to eliminate the issue. Am I right?

As many people above said, .NET itself is a wonderful platform, C# is a dream language (especially after that poor VBScript), but why the default Web programming model for ASP.NET suffers from such a major issue?
ASP.NET proponents above said that .NET is so powerful that nothing stops us from inventing our own model instead of a standard WebForm/ViewState/Server Controls. Sure. One would even able to program server code for Web sites in Assembler... My point is: why the default model which is offered in all ASP.NET tutorials suffer?
re: Downloading a File with a Save As Dialog in ASP.NET
Today @ 12:41 am | by roji

i am facing an issue regarding downloading. i hosted my application in server machine and i try to attach file in client machine as it's attaching the file.But now the problem came while try to download it's not getting the file name.According to my knowledge the application can get the files only in server machine.As i need to solve this issue.while attaching itself is any way to take the client machine name or through the URl and save the attach file in server machine.


If anyone came across this sitution please help me.

Thanks,
Roji
re: Handling mshtml Document Events without Mouse lockups
Yesterday @ 10:12 pm | by abhishek

Can anyone Plz send me the source code for how to handle keyboard events .I am trying to hook the key events but rather then entering my text the system is replacing the character with my text.
Plz help
regards
Abhishek
re: ASP.NET gets no Respect
Yesterday @ 7:21 pm | by Mark Gordon

Rick,

The product doesn't deserve any respect, the problem I have with .NET is the amount of code necessary to create an application compared to a VFP/VB application. .NET is truely a step backwards in most situations. This product is overkill when most businesses want to store some data run a process gen some reports and webenable their app. We dont need 50 ways to do something with 48 of the 50 having some strange gotchas, why do you think Scott Gu has a job he basically documents or in my opinion makes excuses for the development tool. Nor does a medium or small business want to administor an SQL Server application.

Besides the fact Microsoft keeps changing paradigms. They need to develop a paradigm, stick to it and refine it which is what Visual Basic and Visual Foxpro did. Look at the amount of different paradigms changes .NET has had now they are hyping MVC and EDM while some of the basic features are still not even in the package. There still is not a visual control inheritance in the class browser (shock vfp pulled this trick off), sure you can code it out if you work around all the bugs in VS, there isn't a datagrid as part of WPF, LINQ to SQL is still not an industry success, two way databinding is missing in webforms even simple stuff like format and inputmask properties this is a joke.

That is why the hype is gone people have migrated to the crap development tool and realize there is alot of cost and no real benefit other then Microsoft stopped development on their tool kits that actually where productive and RAD environments.

For us "mortal" programmers that actually have to go out and quotes jobs try walking into a company with 50 employees and a current foxpro application and tell them then have to buy SQL Licenses, new hardware to run the application on top of the development cost which in every case to date I have seen .NET is more then a VFP or VB application. Or have you seen the BAD .net application being deployed which I get called into to try and fix all the code is everywhere, it is a clusterf*, code in the html markup, javascript, poorly implemented ajax mixed in and cut, copy and paste is used everywhere there are no standards! Microsoft really has screwed over the small developers and small to medium size business market. I would stop using this .NET crap tomorrow if I could.

I wish more developers would quit defending the .NET monster and call a spade a spade already.
re: Missing PageMethods on an MS AJAX Page?
Yesterday @ 2:58 pm | by Trevor

Sigh, same problem, get undefined error, have double checked all the problems, done IISReset, restared dev servers, brand new VS project with the very simplest of scenarios, same problem, undefined errror.

The proxies seem to be getting generated (although maybe they are old ones that are not getting rebuilt.)

I am on VS2008, 3.5 SP1
re: ResolveUrl() without Page
Yesterday @ 1:56 pm | by Chuck Wagner

slight change to Wiktor and AC's code...now we can all argue about the implementation of IsAbsolutePath ()

    /// <summary>
    /// Returns a site relative HTTP path from a partial path starting out with a ~.
    /// Same syntax that ASP.Net internally supports but this method can be used
    /// outside of the Page framework.
    /// 
    /// Works like Control.ResolveUrl including support for ~ syntax
    /// but returns an absolute URL.
    /// </summary>
    /// <param name="originalUrl">Any Url including those starting with ~</param>
    /// <returns>relative url</returns>
    public static string ResolveUrl(string originalUrl)
    {
        if (string.IsNullOrEmpty(originalUrl))
            return originalUrl;

        // *** Absolute path - just return
        if (IsAbsolutePath(originalUrl))
            return originalUrl;

        // *** We don't start with the '~' -> we don't process the Url
        if (!originalUrl.StartsWith("~"))
            return originalUrl;

        // *** Fix up path for ~ root app dir directory
        // VirtualPathUtility blows up if there is a 
        // query string, so we have to account for this.
        int queryStringStartIndex = originalUrl.IndexOf('?');
        if (queryStringStartIndex != -1)
        {
            string queryString = originalUrl.Substring(queryStringStartIndex);
            string baseUrl = originalUrl.Substring(0, queryStringStartIndex);

            return string.Concat(
                VirtualPathUtility.ToAbsolute(baseUrl),
                queryString);
        }
        else
        {
            return VirtualPathUtility.ToAbsolute(originalUrl);
        }

    }

    /// <summary>
    /// This method returns a fully qualified absolute server Url which includes
    /// the protocol, server, port in addition to the server relative Url.
    /// 
    /// Works like Control.ResolveUrl including support for ~ syntax
    /// but returns an absolute URL.
    /// </summary>
    /// <param name="ServerUrl">Any Url, either App relative or fully qualified</param>
    /// <param name="forceHttps">if true forces the url to use https</param>
    /// <returns></returns>
    public static string ResolveServerUrl(string serverUrl, bool forceHttps)
    {
        if (string.IsNullOrEmpty(serverUrl))
            return serverUrl;

        // *** Is it already an absolute Url?
        if(IsAbsolutePath(serverUrl))
            return serverUrl;

        string newServerUrl = ResolveUrl(serverUrl);
        Uri result = new Uri(HttpContext.Current.Request.Url, newServerUrl);

        if (!forceHttps)
            return result.ToString();
        else
            return ForceUriToHttps(result).ToString();

    }

    /// <summary>
    /// This method returns a fully qualified absolute server Url which includes
    /// the protocol, server, port in addition to the server relative Url.
    /// 
    /// It work like Page.ResolveUrl, but adds these to the beginning.
    /// This method is useful for generating Urls for AJAX methods
    /// </summary>
    /// <param name="ServerUrl">Any Url, either App relative or fully qualified</param>
    /// <returns></returns>
    public static string ResolveServerUrl(string serverUrl)
    {
        return ResolveServerUrl(serverUrl, false);
    }

    /// <summary>
    /// Forces the Uri to use https
    /// </summary>
    private static Uri ForceUriToHttps(Uri uri)
    {
        // ** Re-write Url using builder.
        UriBuilder builder = new UriBuilder(uri);
        builder.Scheme = Uri.UriSchemeHttps;
        builder.Port = 443;

        return builder.Uri;
    }

    private static bool IsAbsolutePath(string originalUrl)
    {
        // *** Absolute path - just return
        int IndexOfSlashes = originalUrl.IndexOf("://");
        int IndexOfQuestionMarks = originalUrl.IndexOf("?");

        if (IndexOfSlashes > -1 &&
             (IndexOfQuestionMarks < 0 ||
              (IndexOfQuestionMarks > -1 && IndexOfQuestionMarks > IndexOfSlashes)
              )
            )
            return true;

        return false;
    }

re: Unable to debug Web Site with Top Level Location
Yesterday @ 5:49 am | by Guy Harwood

Im actually debugging an app that works like this right now, based on your previous post about that location tag attribute. Its actually outside of the main app on my local machine because debugging didnt work - so this is good to know!

one thing i am finding is that authentication seems to be erratic on the live site since we used the 'inheritInChildApplications' attribute. People are having to re-login multiple times in a 5-10 minute session. Whether its related or not i cannot be sure. But its damn annoying and very difficult to track down.
re: Missing PageMethods on an MS AJAX Page?
Yesterday @ 5:10 am | by Perley

Same problem. Although I find if I perform an action on the page (causing a postback) the PageMethod will be found. Also even when the error occurs everything is showing fine in the source so that it should find the PageMehod with no problem. Wondering if I need to rebuild my development platform (old AJAX being found somewhere) or is it just a really starange quirk?
re: Unable to debug Web Site with Top Level Location
Yesterday @ 3:48 am | by Kamran Shahid

Good One Rick
re: Lost (and found) Visual Studio Templates in Web Project
Yesterday @ 1:40 am | by Danijel

Man, with all of these problems described on your blog, you really have a bad karma :))).
re: Dell Laptop Battery Blues
Wednesday @ 10:50 pm | by Rich O

Only 1-2 years??? I have a Toshiba Satellite.

Looks like it was setup 4/30/2002 ... I have used this very steady since at least 1/2003

Still original battery. Normal usage is plugged in. Occaisional battery use.

I can still get over 1 hour of work while on battery.

Now, maybe this little machine was used to squash a radioactive spider and its just something special ... but, I think I just managed to get one of the old-style solid-build machines.

<knocking on wooden desk>
re: jQuery AJAX calls to a WCF REST Service
Wednesday @ 10:35 pm | by Travis

Nice article. What if you want to use the json enabled wcf service in another domain. I understand the implications of this, but I have yet to understand the how. Any recommendations for me? Some have said to use callbcks, which all similar to how other company's have done so for widgets. I am not sure where I should start.

-Travis
re: Lost Ability to run Click Once
Wednesday @ 9:28 pm | by Zaw Han

I am also having the issue. I tried uninstall and reinstall IE7, IE8 beta, clicked on change button for .NET frame work 2 service pack 1 and still having the issue. Install clickonce Addon for Firefox and it works but still have no luck with IE. I have XP Professional. Please help...
re: Understanding ASP.NET Impersonation Security
Wednesday @ 2:05 pm | by Ron

Just wanted to say this was a great article. They way you explain everything is so clear and I love it. Thanks for the great information. God bless.
re: ASP.NET gets no Respect
Wednesday @ 1:09 pm | by Peter

Hey Rick,

As ever a great article. My problem has always been that if you do it the ASP.Net way it's very difficult to use the tools / scripts etc that the rest of the guys are using. Microsoft constantly try to wrap everything up in such a way that you can't get to the stuff you need too. For simple CRUD cases it's a blessing but through accessibility or web2.0 in the mix and it all breaks down really badly.

Thankfully MVC.Net is on it's way and that means we'll finally get control back. It will be heaven. In the meantime ...

Also. We don't have any "killer apps". PHP has Joomla, Drupal, Social Networking and everything else you could possibly want. We have DotNetNuke *blush* and a couple of others like Umbraco that look more promising. If choosing ASP.Net means building your app from scratch its no wonder people go for PHP.

Cheers

Pete
re: Server Errors when updating live Web Applications online
Wednesday @ 12:56 pm | by Rick Strahl

@Milo - there's really no way around downing the AppDomain when you are replacing assemblies because assemblies loaded must unload in order to be replaced. .NET cannot unload assemblies once they are loaded so no matter what you have to shut down the AppDomain for the changes to be recognized and that means taking InProc Sessions down with your app.

If Sessions are critical in your app you shouldn't be using InProc sessions anyway - using OutOfProc or Sql Sessions will let your sessions survive AppDomain and AppPool restarts and is a much better choice if Session data is essential to visitors of your site.
re: Moving my Site onto a 64 Bit Server
Wednesday @ 12:50 pm | by Rick Strahl

@Bartek -that's a bummer.

503's are caused by the rapid fail limits which often can cause problems when you first get a site up and running before everything is configured properly. In fact that DID happen to my 32 bit sites as well because the ISAPI extensions weren't configured right and crashed the process. One of the first things I do in most AppPools is turn that feature off (or at least bump the retry count a lot higher) on ANY AppPool.
re: Server Errors when updating live Web Applications online
Wednesday @ 10:59 am | by Milo

When you "down" the site, I'm guessing you drop all the session with the .net reflection event when the files are updated. Can you not involved the "pause" action to allow the service to continue serving transient visitors and stop new sessions? Waiting for 90 second would possible allow the majority of visitors but not guarentee all of them...

Just forcing a pool reload isn't very elegent for visitors.

Does anyone address this?
re: Server Errors when updating live Web Applications online
Wednesday @ 10:49 am | by Matt Davis

Also check out: http://msdn.microsoft.com/en-us/library/e1f13641.aspx

You can set config values like 'waitChangeNotification', so the app won't recycle right away. Giving the file system a chance to catch up with the writes.
re: Moving my Site onto a 64 Bit Server
Wednesday @ 4:55 am | by Bartek Marnane

Hi Rick,

Glad things worked for you, I ran into all sorts of issues trying to force an IIS application to run as 32 bit on my 64 bit server...

http://blog.evonet.com.au/post/2008/08/22/503-service-unavailable-errors-when-IIS-running-in-32-bit-mode-on-64-bit-Windows-Server-2008.aspx

Great article though!


West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2008