Tag Archives: ASP.NET

Thoughts on the Future of Microsoft Development #pdc2010

The PDC was last week. I have never been (was scheduled once but didn’t end up going), but I try to keep up with everything that they have online, and now even more the blogs and tweets. Here are my thoughts after digesting everything I could.

Strategy

I’m not sure this much of one.. but Microsoft is still trying to figure out and find their development strategy. From back in the 90’s when it was Win32 then MFC and ASP Classic with VBScript + Office/VBA, to then Managed code (.NET C#/VB.NET, and ASP.NET Stacks).. and then WPF/Silverlight, they still and always will keep changing so that developers have to keep learning new things and looking at the next shiny object. There hasn’t been much of a convergence or steady path though. It seems once a developer or team picks up a technology it is already outdated, and I am guessing this will never change.

Anyways, after watching the videos and seeing discussion, this is what I think..

1. HTML5

The web! Ahh, the web. The one place there are no restrictions. Apple is saying, develop under our restrictions, or go out to the web with HTML5, and Microsoft is going to follow suit. If it was ASP Classic, or ASP.NET WebForms, and then MVC, and now HTML5, the web will be around for a while and Microsoft doesn’t want to get left behind. For a while they were touting Silverlight as the “new web” or whatever, but that seems to have changed.

Web applications are good for some things – well, a ton, but not everything. You can’t do some of the richer things you can do on a client on the web, deeper integrations. You can’t really run a web app offline either, no matter what people say, it just won’t be the same as a fat client. Anything I hear from MSFT that says, it does “X” if you use IE9 and I just cringe. Forget IE, let’s make it work for all browsers.

2. Silverlight

If you are developing for the WP7 Phone (who has one? yeah – I thought so), you use Silverlight, other than that, not 100% sure where they are going with this. Use it for video streaming? Games? Flash killer? Basic RIA application that needs a little more integration with the desktop than a standard web app, but less than a fat client. The problem is, what you can and cannot do in Silverlight changes every release – In my opinion they should open it up more, let you do more things with the desktop. Let devs focus on just one set of rules. I have a feeling that Silverlight might just be used as a “glue” technology instead of a “main” technology. The glue between Web and Windows?

3. WPF

Unknown here. Not much at PDC, but some talks. Winforms (like Webforms) is a forgotten technology at MSFT, so to all the people who jumped on those trains, sorry, you need to hurry up and get on the new trains. I have read some places that WPF is the future for desktop/fat client apps at MSFT, and other places where there is no Product Manager, there is barely a team, no support, they are letting it die (ala Winforms), but who knows for sure. What should a developer do? Enterprise and Line of Business applications that need desktop integrations can’t be created in Web or Silverlight, and .NET developers really don’t want to fall back to C++ (although Evernote did – and saw a huge performance gain). Microsoft needs to instill some confidence in developers that a technology they would choose isn’t neglected – to me that is just piss poor business practices. On one hand let’s market the hell out of it (which with WPF really hasn’t been the case, but marketed way more than Win32 or Winforms) and get everyone on the bandwagon, and then let it die, and 2 years later say “X” is the brand new toy you need to focus on. They finally are doing some things at MSFT in WPF, but to what extent? Black magic embedding WPF controls in Winforms or Win32 apps? To me, seeing the pretty awesome data binding stuff with WPF makes it a no brainer. Why not extend the enhanced data binding to Winforms? Why make devs switch?

 

Like I said, more convergence of tools. Use expression blend for front ends? Yes! – but it should be for everything, Windows/Web/RIA, not just Windows/RIA. Language constructs getting to the same level no matter where you code? Yes – sounds like a good thing to me, so why is it so tough?

The new Async framework looks sweet, what else for Windows devs on the .NET side? Can we get some more detailed strategy from Microsoft on where things are going? What to focus on? Companies and developers are stuck making a leap of faith when choosing which technology to use – to make sure they aren’t left in the dust. On the Apple side, it is pretty clear – use Objective C and you can code for Mac, iPhone, iPad, etc. use HTML5 for the web. Should we all be using Java? or C++? Why have .NET devs struggle to figure out what technology to use? So bottom line..

 

1. Web – HTML5/ASP.NET MVC, WCF services, etc

2. Mobile – Silverlight (aside: what ever happened to the .NET CF?)

3. Windows – WPF, WPF, WPF (but don’t forget about console apps and windows services!)

It would be interesting to go to Microsoft dev shops around the globe and do surveys..

“Hey there – what are most of your websites and web services written in?”

    Answer: “Webforms and ASMX services -  we are looking at MVC”

“Hello, what are you doing for mobile development?”

    Answer: “Well, since WP7 phone just came out and who knows if it will take off, we do everything in Objective C for iOS devices or just have a mobile website in ASP.NET webforms, or we have some Java based Android app, and some crappy Blackberry apps or something..”

“Hola, what are you doing for your LOB desktop apps, etc?”

    Answer: “Well we have a few legacy VB6 apps, some Win32 apps, and we have poured tons of time into Winforms over the last 7-8 years, but we want to start looking at WPF”

I bet a majority of the answers would be similar to the ones above. Who the hell is doing anything in Silverlight? Niche apps/markets? What about WPF? A few, and some proof of concepts, but yeah, even the MVC stuff is probably on a slower adoption rate then MSFT would like. Not sure how they solve this problem. One way would be to STOP CHANGING THINGS EVERY TWO YEARS so that dev shops can focus and incrementally move to the new technologies, but I don’t see that happening.

Where do we go from here? Well, I am pretty excited to see what .NET 5 brings. :)

Advertisements

Windows 7 – ASP.NET Temporary Internet Files, Assembly Redirects

Just updated my work laptop to Windows 7. Sweet right? Except now the fun of getting everything to work.

First issue I ran into, a Web App in development, not being able to load up “Microsoft.AnalysisServices.AdomdClient” because it was looking for version “9.0.242.0” – the version you get with Office 2007, SQL 2005. But I have 2010 running and SQL 2008 stuff on this new build, so saw that issue. Of course I could install the stuff from SQL 2005, the drivers, but also I can redirect my assembly in the Web.config

          
            
            
          

I was also getting some weird stuff about permission denied to any third party assembly when trying to debug/run it locally. Since the web app is impersonating a user, I figured I need to give that user rights to the temporary internet files for ASP.NET, which worked, but in Win7 (and Vista?) the path is different, it is

%LocalAppData%TempTemporary ASP.NET Files

I gave the user modify and my app finally builds!

Hopefully not too many more roadblocks going forward..

Switching Hosting – Moving to Media Temple (MT)

A few months ago I decided to consolidate my hosting and sites to one server, and I went to Server Beach, and got my own Windows 2003 server. I needed ASP.net and PHP for some things I had so it was kind of a unique situation.

Server Beach is awesome, and if I needed more control I would definitely go back, but I decided it was too money for what I was doing, so I found Media Temple (MT). They have one click WordPress install which was nice, and you can host like up to 100 sites on one account on their “grid” service, for like 20 dollars a month.

What this did leave me with though, was I needed to convert the services I had in ASP.NET to PHP, so a week or so ago I decided to make the switch and converted those services over. PHP just reminds me too much of ASP Classic, very hacky and you have the ability to just put anything anywhere. Oh well, it works now and all my sites are over there for now (except a couple that I will move when their hosting expires). I am liking MT so far and hopefully it goes well, its cheap enough and allows me to do what I need.

I do like that they have the MySQL admin available so you can manage the DB’s directly. In one of my sites, I had to update all the posts at once, and I just wrote a query to do it, saved a ton of time.

Now if I can just get all my DNS and domain registrations in one place, I will be set :)

.NET and Oracle – Match Made in Hell (Data provider internal error(-3000) [System.String])

At my new gig, I am working on a project that is ASP.NET with an Oracle Database backend. Today I ran into an error.

Data provider internal error(-3000) [System.String]

What does this error mean? Heck if I know, its a generic error basically telling you that something is wrong with your connection to the database more than likely.

After troubleshooting code, the CSLA framework, more code, stored procs, queries, more code and testing everything I could think of, I decided it had to be something with the Oracle driver on my machine. I remembered back in the day when I worked for SCWH using Oracle 8 and having a hell of a time getting it to work if the driver was even a .1 release off, or if you were using the wrong driver.

Reinstalled the 10g client and Oracle Data Provider for .NET stuff and it worked. What a waste of time. Just another reason why I hate Oracle, and SQL Server is the way to go. No stupid dot releases of drivers that cause headaches. Granted MSFT used to have MDAC which was a major pain, but with .NET it just connects, and works.

Auto Submit Form in ASP.NET With Javascript

Not sure if this is the best way to do this, but this is what I do. Say you want to auto submit a form on an aspx page. You can call document.formname.submit(); from the body onLoad event and it will submit, but ASP.net will automatically post it back to itself.

I tried added buttons with different postbackUrl’s, clicking the submit button in javascript, etc to no avail.

First, what I had to do was put on my ASP Classic hat. Look at your <form> and remove the runat=”server”

Then, you can say document.formname.submit(); and it will submit your form.

How do you pass data though?

Well, you have to created input fields, probably hidden like

<input type=”hidden” name=”blah” id=”blah” value=”<%= Request.QueryString[“myvalue”] %>” />

Then you can pass data from another page or whatever and auto submit your form.

It would be nice if you could say in your Page_Load() something like

 

btnSubmit.Click(); and it would automatically click it and submit your form, but that doesn’t seem to be available at all.

Like I said, there is probably a better way to do this, and it shouldn’t be this complicated, but a few minutes googling for answers left me up in the air. Funny how something that is so easy in ASP Classic turns out to be harder in ASP.NET. ASP.NET wants you to really post back to the same page by default. It hijacks the “action” attribute on the form no matter what with runat=”server on there.

ASP.NET C# – Grabbing a posted file and save to disk

Sometimes you want to grab a file posted to a page, maybe an image upload or other file upload

HttpFileCollection logFiles = Request.Files;
string path = System.Configuration.ConfigurationManager.AppSettings[“LogPath”];
if (logFiles.Count > 0)
{
HttpPostedFile logFile = logFiles.Get(0);

logFile.SaveAs(path + System.Guid.NewGuid().ToString() + “.log”);
}

As you can see, I am setting the log path from the config. The reason for this is, the path to save to is absolute, something like c:blahblahwhatever

I am saving the file with a GUID as the file name, for uniqueness, but you can grab the name form the file object as well. There are some other gotchas. 4MB limit on files, unless you tweak the HTTP runtime in the web.config, also, you need to make sure that Network Service or ASPNET user has rights to modify the log folder you are writing too. Otherwise you can impersonate a user in the web.config, and make sure that user has rights.

ScaleOut StateServer

ScaleOut Software has a product to manage sessions on a web farm. I have tried this product and have had nothing but issues. I did actually end up getting it working once, but it turns out, even when it does work correctly, it gives your network problems

It seems that the fix for any issue is “You arent running the latest version” – which might be true, but many times, we would be running version 1.3.2 for example that we downloaded two days ago, and then they release 1.3.2.1 the day after we downloaded 1.3.2 – this is a cop out in saying that its on our end, when in reality it is just buggy software that has releases every other day to fix bugs. I dont know if there is any other competing product in the market right now though, so they kind of have it locked. You can use Microsoft’s ASP.Net Session provider, but that is limited when in a farm scenario. Using MSSQL for your sessions has performance issues. I have heard that ex-microsofties tell people to just roll their own, but that seems too much, especially in a small shop. Hopefully ScaleOut gets more stable, because it could be a good product, if it just didn’t cause issues :)