Modifying a compile asp.net assembly when no longer have source#

So while I was at the MVP Summit, an old client got a hold of me and said there was a weird error on the site when a user was trying to post something.  He sent me a screenshot and it said could not login as sa to sql server.  I remoted into the server where they had moved the application and looked in the web.config file and did not see any connection string that had sa as the user name.  So I was stumped.  I began to look at the stack trace and realized which assembly this was coming from.  This happened to be the only assembly which did not have the source code on the server.  I wrote the app over 6 years ago and the laptop the source was on had recently had a failed hard drive.

Anyway, it was a vb.net 1.1 app from visual studio 2003.  Yes I used to do a little VB. :)  So I realized that there must have been a connection string hard coded in the assembly where the stack trace was coming from.  Oh no!  How was i going to fix this without changing the sa password on their new host which was not really an option? 

First thing I did was download reflector here. I opened the assembly and did see the hard code connection string.  Man what an idiot for doing that.  Don’t know why I did that at the time, but not a very smart move. So I was stuck.  How do I edit an assembly without having to export all the code from reflector, find visual studio 2003 and run it in a virtual, download the rest of the app and pray that I could get it to work.  Well i searched for modifying a .net assembly and found this: Reflexil - http://sebastien.lebreton.free.fr/reflexil/ . It is a plug-in that works inside of reflector that allows the modification of the code in the assembly.  So i downloaded it opened the assembly, changed the connection string code and then saved it.  The .dll ended up being a third the size, but still worked after deploying it to the server.  I was shocked.  I just had edited a vb.net 1.1 assembly on a windows 7 laptop using reflector while in a session during the MVP summit.  Pretty cool I think.  Saved me a whole day of figuring out how to run visual studio 2003 and get that code compiled again.

Wednesday, March 25, 2009 7:42:51 AM UTC #    Comments [3]  |  Trackback

 

Windows 7 and My 2 year old Laptop#

I have owned a Dell Inspiron 9400 for almost 2 years with Vista Ultimate and have enjoyed it for the most part.  I had some issues with wireless and getting the sluggish feeling after I had visual studio, 20 browser tabs open, iis 7, sql server, etc. all open at the same time.  Of course I thought, well i have a lot of stuff running at same time so of course it will be slower.  Well now with Windows 7 I have not one wireless issue, speed is crazy faster and I  am still only using 1 gb of ram of 2 gb available. 

I am absolutely shocked a how much better I like my laptop.  I have a 8 Gb Vista 64 desktop at home, so my laptop is always going to seem sluggish, but now I really like using my laptop.  I am not looking forward to having to wipe it again when the beta expires, but is well worth the joy i now get from my laptop. 

Windows7DesktopSmall

I love the new task bar and my favorites always being down there.  I can’t remember if I have even done a full reboot in a month.  Oh if you are going to try this at home, make sure to do a clean install. 

Tuesday, February 24, 2009 9:00:35 AM UTC #    Comments [2]  |  Trackback

 

Enabling 301 redirects on IIS 7 on Windows server 2008#

I was stumped the other day as to why i could not get a 301 redirect in from site.com to www.site.com on IIS 7.  After much looking around I found out that you need to enable this feature in the server manager. 

image

Then you need to go back to the IIS node that you want to enable 301 redirect for:

 

image

And then set the values for your redirect:

image

If you notice what is also cool is that it will redirect addresses relative to the domain and not just to the root (i.e site.com/oldfile.htm will redirect to www.site.com/oldfile.htm

Hope this helps someone, cause it was not very intuitive for me to find out how to do it since the feature was not installed by default.

Thursday, February 05, 2009 10:37:27 AM UTC #    Comments [2]  |  Trackback

 

ASP.NET MVC 1.0 Release Candidate Is Released#

Time to dig into the T4 template system (learn here) in Visual Studio since they added a cool feature for generating scaffold controllers and views. Check out ScottGu's Article, of course. I am thinking that this was influenced by the SubSonic MVC Scaffold Addin from Rob Conery a little bit ago. I am so happy that we are going to have our own scaffold playground with built in tools. It is getting so much closer to how I really want to develop web apps. Woohoo!

I know it has been a long time since i blogged, since before the holidays. Four kids is a little bit busier than I imagined, but all worth it. I am still trying to stay up late to learn more new things coming out in the web world, as I love the information overload. Much more to come soon I am sure!

Just found this link. You will need this to check out the MVC futures stuff that has Html.TextBoxFor(p => p.PropteryName).

Wednesday, January 28, 2009 8:31:47 AM UTC #    Comments [1]  |  Trackback

 

How to speed up your ASP.NET Website#

Recently we noticed that our site was a little sluggish.  Now of course when we started to look at why it was slow sometimes and not others, we opened up a huge can of worms.  Was it our code?  Was it our server?  Was it our proxy server?  Was it our database?  Was it our graphics?  Was it the JavaScript?  Or was it just that the end user had a slow connection?  Well it was all of them. 

Sometimes we forget that not everyone has FIOS.  We are very lucky to have a 20 Mbps / 20 Mbps connection at work.  So first thing we did was to look at the size of our pages when downloading the html, CSS, images and JavaScript.  We were shocked at the size of the files.  The first eye opening fact was that our home page was 1.5 MB.  Whoa.  The best tool that we found to figure the details out was YSlow.  Here is a snippet from their site about what the tool does:

YSlow analyzes web pages and tells you why they're slow based on the rules for high performance web sites. YSlow is a Firefox add-on integrated with the popular Firebug web development tool

This tool saved us so much time figuring out what our issues were.  I highly suggest reading the rules.  Also you can listen to a recent podcast from DotNetRocks: YSlow! Steve Souders finds Website Bottlenecks

So we began the process of optimizing the client.  The first thing you can do is to compress the JavaScript, CSS and html files on the server to reduce the file download size up to 75% on the client.  The way to do this in IIS6 is to enable GZip compression.  This is turned off by default which I think should actually be turned on by default.  Here is some info on how to enable it for specific file types.  Don't forget the .axd files if you use and Ajax in webforms.

Using HTTP Compression for Faster Downloads (IIS 6.0)

So next on our list was minimizing the size of the images that we were using as backgrounds in CSS.  They are the first calls from the browser when loaded from CSS.  Also moving JavaScript references to the bottom of the page helps.  The browser using a blocking request when loading JavaScript files, so if you have them at the top of the page, you will get a perceived load issue since the browser waits for that first.  The best thing to get out of optimizing for the client is the perceived load to the user which really makes the most difference.

So after removing the client side issues we realized we had a database load issue on certain pages with many records.  Well we found out we ran into the famous ORM gotcha of way too many queries when using strictly the data objects with related foreign key objects.  For instance, by relating a member record to the aspnet user table and doing a foreach on the member and then checking to see their username on the aspnet user table, it will cause another db query to get that info for each user.  Sometimes when using the orm objects that are generated instead of writing a custom query to populate your own domain object, you can get into a lot of trouble.

Our website has many applications to it, some mvc and some using webforms.  We have noticed a significant speed increase on the mvc sites.  There is less code to render and there is no Viewstate so right away there is some performance increases. 

I hope that this helps some other people figure out why their site is slow for some people some of the time.

Wednesday, December 10, 2008 9:52:17 AM UTC #    Comments [5]  |  Trackback

 

Missed PDC 2008? Go to MSDN Developer Conference#

If you missed PDC 2008 in L.A this year, you can catch some sessions at the MSDN Developer Conference in Orlando on December 11, 2008. It's only $99, so I am sure the registrations will fill up fast.  Here is a blurb from their site about what it will cover:

We’re bringing the PDC to you! For just $99 you’ll get the best of the PDC in your own backyard and hear all of the exciting announcements around the Azure Services Platform and Windows 7. Other sessions include the latest developments in .NET, Silverlight, Surface, Parallel Programming, Live Mesh, and more.

Register today to stay current in an ever-competitive job market, enhance your skills and gain access to the next generation of tools and technology.

  1. Experience the Azure Services Platform
    Create applications that seamlessly bridge PC, Web, and phone
  2. Be among the first to see Windows 7
    See the latest advances in Multi-Touch Application Development
  3. Take your .NET skills to the next level
    See sessions on WPF 4.0, Silverlight 2, ASP.NET 4.0, Parallel Programming, Live Mesh and more

The Cost? Just $99.
And, did we mention that attendees will get some cool giveaways?

 

For more information, here is a link to the site and registration page

http://www.msdndevcon.com/Pages/start.aspx

See ya in Orlando!

Monday, November 10, 2008 7:45:16 AM UTC #    Comments [5]  |  Trackback

 

Scaffolding in an ASP.NET MVC App#

So at work I had to create a simple admin for a few new features in our app and decided I would try out a few new technologies while I was at it to not only save some time, but to see what is out there now.  My heart was set on this being a simple MVC web app, but really wanted to try ASP.NET Dynamic Data also.  Well good news is that you can use Dynamic Data in MVC fairly cleanly and easily.  By adding a simple route to the global.asax.cs file you can easily have Dynamic Data working although it is web forms based:

 MetaModel model = new MetaModel();
            model.RegisterContext(typeof(MvcApplication1.Models.NorthwindDataContext), 
                new ContextConfiguration() { ScaffoldAllTables = true });
            routes.Add(new DynamicDataRoute("DD/{table}/{action}.aspx") {
                Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }),
                Model = model
            });

Now this opened my eyes a little that you can easily create a hybrid web app of MVC and Web Forms.  Web Forms does have its advantages sometimes, especially when you start looking at existing tools and controls that you just need to work quickly and don't feel like reinventing the wheel.

You can download a sample project of this working in an mvc app over at codeplex. http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=14473

That same night I was playing with Dynamic Data, Rob Conery had just posted his prototype of a Subsonic MVC Add-in for Visual Studio.  I was pretty impressed with the code and views that it generated, and I think is a great start to seeing what is possible.  Both samples took less that an hour to download and implement.  I ended up spending more time integrated security across the multiple web apps on different sub-domains than getting the scaffolds to work.

Wednesday, October 29, 2008 8:10:43 AM UTC #    Comments [3]  |  Trackback

 

jQuery and Microsoft#

I was always hoping this might happen.  Support from Microsoft along with distribution of jQuery with Visual Studio and ASP.NET MVC.  Scott Guthrie and Scott Hanselman along with John Resig have some more detail in their posts.

I plan to update my post, Ajax Control Toolkit and ASP.NET MVC, to use jQuery and the toolkit.  It is about using CSS selectors and the Ajax control Toolkit as an alternative way to use the toolkit in any web development platform.  I modified the Microsoft Ajax library to support CSS selectors, but it is a poor hack and would much prefer to use jQuery anyway.  I was trying to see if I could make it work with the Microsoft Ajax Library from their old preview version from last year.  I was wondering if they would try to reinvent the wheel.  I am glad they decided not to.

Monday, September 29, 2008 4:57:19 AM UTC #    Comments [3]  |  Trackback

 

 

All content © 2010, Jim Zimmerman
Book
New Book
Links to me
On this page
Sponsors
Calendar
<March 2009>
SunMonTueWedThuFriSat
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234
Archives
Tags
Blogroll OPML
Technorati
Favorite Links
Disclaimer

Powered by: newtelligence dasBlog 1.9.6264.0

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail