One of the changes in
asp.net 4.0 that I discovered the hard way last week has to do with request validation. I created a web service with a few methods that allow an application to send email messages using an email marketing service instead of our SMTP server, very simple nothing complex.
The problem
We can call and execute the web methods from our web application without a problem, everything works. However, when we tried to execute one of these web methods where the message's body is a parameter, and we executed it from a browser using query strings we got a request validation exception.

It turns out that in
asp.net 4, request validation is enabled by default for
all requests, because it is enabled before the BeginRequest phase of an HTTP request. Request validation applies to all requests and not only to .aspx page requests, for example, our .asmx web service call.
Because of this, you might see an error like the one shown below, an error you didn't see prior to
asp.net 4 because request validation was enabled by default in previous versions of the framework but it only applied to
asp.net pages (.aspx).
This is the error message:
System.Web.HttpRequestValidationException:
A potentially dangerous Request.QueryString
value was detected from the client
The solution
To turn off request validation in
asp.net 4, you need to add the following to your web.config:
<httpRuntime requestValidationMode="2.0" />
As always, remember to analyze any request validation errors and check for unsafe HTTP inputs to avoid the potential of XSS attacks.
It happens to all of us, unfortunately the reason you are reading this is probably because it is happening to you now.
Let's say that your boss comes in one morning and asks you to work in a project, then he mentions you need to get it from Visual SourceSafe (VSS)... you think is a joke until you noticed that your boss has that "serious" look in his face. F*ck. Or maybe you receive the project in a compressed file and when you try to open it, you realize this project was under Visual Source Safe at some point.

Visual Source Safe (VSS) was an OK product years ago, it has been for a number of years, in my opinion, a bad choice for a source control system. This is the reason I personally do not like it and do not recommend it, from Wikipedia:
The criticism concerning instability stems largely from the way Visual SourceSafe uses a direct, file-based access mechanism that allows any client to modify a file in the repository after locking it. If a client machine crashes in the middle of updating a file, it can corrupt that file. Many users of Visual SourceSafe mitigate this risk by making use of a utility provided by Visual SourceSafe that checks the database for corruption and, when able, corrects errors that it finds.
I concur with the above, I experienced the file corruption issue with VSS multiple times in the past.
Today, I use tools such as Subversion and CVS. More recently, I have been using Mercurial too, which is a Distributed Version Control Systems (DVCS) just like Git. I do prefer Mercurial over Git, however that is a talk for another time.
Enough with the what and why, below I show you the steps you can follow to remove Visual SourceSafe dependencies from a Visual Studio solution and project(s).
Grab a fresh cup of coffee or your favorite caffeinated soda and follow the steps below:
1- Go to the folder containing the solution files and delete the following:
mssccprj.scc
[YourProjectName].vssscc
vssver.scc
*.vspscc
2- Open [YourSolutionName].sln in your favorite text editor and remove the following section:
GlobalSection(SourceCodeControl) = preSolution
...
EndGlobalSection
3- Go to the folder containing the project files and delete the following:
[YourProjectName].vbproj.vspscc
mssccprj.scc
vssver.scc
*.vssscc
4- Open [YourProjectName].vbproj in your text editor and remove the following lines:
SccProjectName = "SAK"
SccLocalPath = "SAK"
SccAuxPath = "SAK"
SccProvider = "SAK"
Now you can open the solution/project without getting those ugly visual source control errors.
I hope this is useful to you, take care.
This might be something you already know, however I just found out about it and I am writing it down to share it with you and to help myself find it in case I forget about it which will probably happen.
In the past, when working with Visual Studio projects downloaded from the web, or projects that are shared with other developers, every once in a while I ran into the issue of not being able to load the project in Visual Studio because either the path is wrong, or if it is a web project, maybe the project is setup to run on IIS and I didn't have it setup so the project wouldn't load, etc... you get the point.
My way of fixing these problems (up until today) was to close the Visual Studio solution, open the project file using notepad and then make the necessary changes to fix the issue, save it and then reopen the project again. It worked, not a big deal. However, when you have several projects in one solution and many of them are not loading, it is a pain having to close Visual Studio every time this happens, for each project, just to edit the project file with notepad.
Today I found there is an easier way to do this. There is no need to close the project or solution to make changes to the project file. If your project does not load for any of the reasons above, or for any other reason, you don't need to close Visual Studio to open the project file using notepad, yes notepad is great and everything, but if you are already in Visual Studio then I don't know about you but I would like to be able to fix these type of issues without having to close Visual Studio.
This is how your project looks like in Visual Studio when for some reason it doesn't load in Visual Studio:
Right-click on your unavailable project and select Edit
[YourProjectName].csproj, Visual Studio will open the project file using the code editor and you'll be able to make any changes you need to it. I wish I knew about this before. See screen shot below for sample of the project file opened with Visual Studio:
After you are done making your changes, just right click on the project file again and select Reload Project. If the changes you made to the file are good and the project file does not have any more issues, you should be able to see your project in Solution Explorer, see screen shot below:
The above is to show you a way to edit the project file without having to close it and open it in notepad to make changes.
If your project loaded correctly but you still need to make changes to the project file for whatever reason, you can "unload" your project intentionally and then edit it following the steps above. To "unload" your Visual Studio project, just right click on it and select Unload Project. After that you should be able to right click on it again and select Edit to start making changes to it.
Good luck.
Yes, it is midnight or maybe even 2AM and you just realised you didn't finish your to-do list, you didn't accomplish much or maybe nothing, zero, nada, now what...
It happens to all of us, life is just a huge to-do list and the problem I believe, is that most of us try to accomplish too much, we loose focus.
.jpg)
It is easy to loose focus in today's world, with all those tweets and facebook updates around us, all those blogs we
think we need to read, all the email we need to reply to, and all of the things we have to learn to keep ourselves competitive and marketable.
Because of all of the above, we do not keep our focus on what's important at the moment, we think we can multi-task and that is all a lie, we fool ourselves into thinking we can do it all and on time, we can't.
In order to accomplish our goals, we need to make sure we only have a few items in our to-do list every day and concentrate on getting those items done, turn off your phone, close your email, do not open Twitter or Facebook and log off from your instant messaging application. If you have any of those applications open,
you will be checking them every few minutes, believe me, I know.
I am not saying not to use those tools or stop looking at Twitter, instead, make it a routine to use those tools and applications at a determined time of the day if you have to, it will help you concentrate on what actually helps you get the bills paid.
Another suggestion is to concentrate on those tasks we know we need to complete but they are difficult or just not fun to work on, the sooner you start and complete those tasks the better you'll feel. In the end, you'll probably have to still complete those horrific tasks and chances are you'll be in a hurry and stressed out because you are now behind.
To me, preparing our tax return is something I always used to leave until the last few days before the deadline... and it got me all stressed and upset because I was always in a hurry and worry that I was not going to be able to complete it on time. Last year I decided to do it as soon as I collected all the information I needed, usually by the first week of February and that has worked out great for me.
Stop thinking that you need more hours in your day to get things done, we all know that we spent too much time just reading and writing email, checking out Twitter and other social networks, reading news and blogs, watching LOST, or The Office, etc... It is OK to do all those things, I do it too. However, setting an specific time to do each and all of those things helps a lot, we don't feel like we are missing out and at the same time we are producing more by concentrating in our work first.
For example, I am trying to only read email twice a day, so far it has worked OK and Twitter I usually open it when I have a quick question to ask and at night when I spent about ten minutes reading and replying to stuff I am interested on.
The little changes I've made so far to my daily routine, have provided me with more time and concentration to be able to finish my tasks on time and with better quality since I am not in a rush all the time. The small changes to the way I work allow me to get in the zone more often and be more productive. I feel happier.
There are days when for one reason or another this does not work as planned, you get interrupted by one of your clients because a server is down, or a friend calls you to meet for lunch, or your dog wants you to take him out for a walk, etc... and that is OK, it is life, enjoy it, but make sure this doesn't happen all the time or you won't have a client or a server to fix, money to go out for lunch or a dog ;-)
Keep your focus, do less and you'll accomplish more, feel better and have more free time to do what's fun... or not.
Good luck!
Yes, it has been released, this is the new, improved, cool, updated and so much waited for version of
asp.net MVC.
asp.net MVC 2 is out which was officially confirmed by Scott Gu yesterday on his
blog.
I wrote a post about some of the features included in the
release candidate 2 (RC2) just a few weeks ago. This new and
final asp.net MVC 2 has some cool new features such as:
What's New
- Templated Helpers that allow you to specify extra View Data. Basically, this release now includes new overloads for the EditorFor and DisplayFor methods, the overloads contain a parameter that accepts an anonymous object that can be used to provide the extra view data.
- The UrlParameter.Optional property which will save some pain when you are binding to a model that contains an ID property and the property is absent in a form post. See Haack's post for details on how to use this very cool feature.
One of the cool things is that you can run both asp.net MVC 1.0 and 2.0 in the same machine. I think this is cool because you still use the same computer or virtual machine to develop and maintain applications running on either version of asp.net MVC.
The upgrade
We all want the greatest and latest right? Ok, not always but if you do and you are using Visual Studio 2010 (see what I mean by using the greatest and latest), you are in luck because VS 2010 includes an automated upgrade wizard that will migrate your existing ASP.MVC 1.0 applications for you... automagically :)
If you are not using Visual Studio 2010 (shame on you) that is OK. You can still upgrade your
asp.net MVC 1.0 applications to MVC 2.0 by following these very
detailed instructions.
Below are some links to resources that you might want to consider if you want to learn more about
asp.net MVC 2.0 and
asp.net in general.
The
asp.net MVC 2 RC 2 was made available on February 4, 2010, you can download it
here.
This new release has some cool features such as the following:
Areas:
The Areas were first introduced with the MVC 2 Preview 1 release. However, I've decided to include some information about areas since the ASP.NET team has made some changes to this feature since its release.
Areas allow developers to partition large projects into smaller more manageable smaller units that are referenced to as
areas. Each area has the same structure as an
asp.net MVC project, and within an application you can have many of these MVC structures called areas. This new feature helps manage the complexity when dealing with large projects and facilitates multiple teams working together in separate
areas of an application.

After you add an Area, Visual Studio will create a folder labeled Areas and within this folder you'll have your new RSVPS area with the necessary folder structure that allows you to separate the files and the functionality of an specific area of your application:

Model Validation:
This new release uses Model validation instead of Input validation as the previous versions did. This means that now MVC runs all validators on an object, as long as that object has at least one value bound into it during model binding. It also uses Data Annotation for validation
which allows you to add validation rules declaratively to Model and ViewModel classes within an application.

Read
Brad Wilson's blog for details about this change.
The above are some of the new features that I really like and use with ASP.NET MVC 2 RC2. If you want to upgrade your existing MVC 1 projects to MVC 2 RC2 you'll need to do the following:
Upgrading an ASP.NET MVC 1.0 Project to ASP.NET MVC 2 (as described in the ASP.NET MVC 2 RC2 Release Notes)
To upgrade an existing ASP.NET MVC 1.0 application to version 2, follow these steps:
1. Make a backup of the existing project.
2. Open the project file in a text editor (the file with the .csproj or .vbproj file extension) and find the ProjectTypeGuid element. As the value of that element, replace the GUID
{603c0e0b-db56-11dc-be95-000d561079b0} with
{F85E285D-A4E0-4152-9332-AB1D724D3325}.
When you are done, the value of that element should be as follows:
<ProjectTypeGuids>{F85E285D-A4E0-4152-9332-AB1D724D3325};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
3. In the Web application root folder, edit the Web.config file. Search for System.Web.Mvc, Version=1.0.0.0 and replace all instances with System.Web.Mvc, Version=2.0.0.0.
4. Repeat the previous step for the Web.config file located in the Views folder.
5. Open the project using Visual Studio, and in Solution Explorer, expand the References node. Delete the reference to System.Web.Mvc (which points to the version 1.0 assembly). Add a reference to System.Web.Mvc (v2.0.0.0).
6. Add the following bindingRedirect element to the Web.config file in the application root under the configuraton section:
7. Create a new ASP.NET MVC 2 application. Copy the files from the Scripts folder of the new application into the Scripts folder of the existing application.
8. Compile the application and run it. If any errors occur, refer to the Breaking Changes section of this document for possible solutions.
The above instructions are from the Release Notes document included in ASP.NET MVC 2 RC2.
Good Luck!
SimpleProject is a web based project tracking application which I intend to use in my consulting business and in my wife's tax preparation business. If everything goes as expected this is also an application that I will be offering to other solo entrepreneurs and micro and small businesses.
Last night I finally completed the mockup of all the main pages and the navigation, and I am very happy with the results. I want to mention I used
balsamiq to create these mockups and I absolutely love this product, it is easy and simple to use and with a little practice you can really create nice looking mockups.
The next step is completing the database schema, I am probably 60% done with it so I should be able to start coding (finally) this weekend... wish me luck! I have decided to use
asp.net web forms for this project instead of MVC... my decision was based on the fact that I have much more experience with webforms than I do with MVC and this will allow me to move faster... I also have invested time and money on some third party controls that I might end up using for this web application.
About office space...
I am still reluctant about getting a shared office space, it is not cheap, and I know I will only be using it maybe for a few hours every other day or so. You see, I have a full time job and also run a small software consulting business from home on the side and I am very responsible about not using but my free/personal time to work on this startup. I have the idea that having a space where I can do work for my startup is going to help me to think of this as a real business and not only a hobby... but then again I don't know if I can stretch myself (and wallet) by getting a shared office space where I'll have to drive to and also pay a monthly amount for it... I asked a question
here and got some real good answers... but I haven't made a decision yet.
If you have any suggestions please share them with me. And if you have some free time and would like to participate in the beta test for SimpleProject, please sign up
here.
Creating our applications for our users and not us, this is nothing new and it seems logical right? as a software developer we create applications for our users, to help them resolve some sort of issue or facilitate some manual process, etc. This is what software developers do. And in many cases we just open our
SDK of preference and start creating this much needed applications using only our own instincts and preferences.
If it was just this easy, we'll all be making a fortune selling these much needed applications to a lot of businesses out there. The need for software applications to resolve problems and/or enhance existing manual procedures is real. However, my opinion is that most software developers, systems architects and the like spent too much time talking about what framework to use, what programming language, or how to incorporate that new cool language feature that everybody is talking about instead of spending time asking real users what is it that they really need. I know, in many cases we might work for a large company and have the middle man, the business analyst or project manager who tell us what to do, and in most cases this works, however when you are running a Micro-ISV you don't have the luxury of counting with all those people which in many cases, the less people that are involved in a software project the better - I'll be writing about this specific topic in a coming post.
As software developers, we tend to have these endless discussions about the latest tools, technologies, patterns, etc, and most of the times we do enjoy engaging in these discussions, it is fun and sometimes we learn one thing or two. However, this is an activity that does not mean anything to the end user of our applications, in fact, the user can care less what tools the software architect or the developer chooses to build an application, they only care about having the application do what it needs to do and to have it ready for use sooner than later.
For example, let's say we are developing some application that we know a lot of users will be interested on, we have received some feedback from users and have an idea on what it is that they need and want. Now, we have used our wisdom (and experience, etc) to decide we are going to develop this application as a web based application. This is great! no problems there, the issue comes when we start over thinking and arguing about what web technology, framework to use. Maybe we like PHP and MySQL, after all it is free and open source, or maybe we like the Microsoft platform,
asp.net, SQL, etc... and that is OK too. The problem exists when we start wasting time arguing with our team or with ourselves about what technology is better, and often we are bias when making our decision, we usually decide to use what we like and not what we know is better for the specific application and the user base. Most of these discussions are based solely on what we prefer, it is based in our own ideas of what's better and more often than not it has nothing to do with what the users want, we do not make these decisions based on what's best for the user. There are some exceptions, so please calm down and don't get too mad with me just yet.
The truth is that the user does not care about all these details that we as developers care too much about, the user does not have a preference regarding the framework or the programming language, I know is a shocker for most of you... but it is the truth, they are the normal ones, we are the geeks and they don't care about the tools we use. As a developer myself, I love to try new things all the time, but I reserve the use of these new frameworks and technologies for my own little projects, samples, etc... I try to avoid the use of new frameworks and technologies when developing a new application that will be used by real people and in a production environment, I know by experience that trying a cool new control, tool or a new feature is not what's best for my users. It is always possible to use the newest and greatest, it is just that doing this will require more time, will more likely have more bugs and this is not what your user wants, we all should know that by now.
I am building my new
Micro-ISV with this mindset, create software that it is simple to use and simple to manage. My main goal is to build applications for my target audience which is micro businesses and solo entrepreneurs, you can learn more about it
here. I am doing my best to make sure that I create something that adds value to my users, software that helps them do their job and at the same time I am doing this by using the tools that make the most sense for the type of application I am building. After all, the goal is to create something useful, even if that means I will be using tools that aren't too exciting or new for me or my developers... the important thing here is to help my users and if I succeed at that, I'll be happy.
Next time you are creating a new application for a user, or are working in a team that is about to develop a new application, think of the user, think of what is better for them and try not to start developing your product solely based on your own technology preferences.
Good luck!
A week ago I released a new version of my
business website, then I asked for feedback about the overall design of this website using LinkedIn questions. I didn't realize I'll get so many opinions and valuable feedback! It was an eye opening, many people provided very valuable feedback, with details that you usually get only when paying a web designer or design firm.
I have been a member of
LinkedIn for some time now; In the past, I've used it to share knowledge and experience by answering web development questions, and to look for business and job opportunities. It was just now that I thought about using it to ask a question myself and see what kind of feedback and answers I will get. So I posted
this question and needless to say, I was very impressed, the quality of most of the answers I received was very good, some of them even providing detailed information that I used to fix and make changes to my business website right away. All of this just by asking a simple question.
The power of professional and personal online networks is real, I can see how these networks will help me and my business succeed by using its valuable resources such as people's experiences and knowledge.
Are you a
LinkedIn member yet? if you are not, consider creating a profile and if you are already there, then please consider
adding me to your network.
Ricardo.
A few days ago my main machine running Windows XP died on me. Thankfully I bought a small HP box with
Windows Home Server on it to backup all my home computers and also to use as a media server. I am glad I did this.
I decided to get the Windows Home Server because I was afraid I didn't have any real backup solution for all of my computers at home. There are 3 workstations, all running Windows XP, a MAC workstation and three laptops running Windows Vista, Windows XP and one is a MAC.
Up until a few months ago I was doing manual backups, saving them to a shared folder located in one of the workstations. It was time consuming and painful... and then I discovered Windows Home Server. This neat little server allows me to do full backups of all my computers, and it also provides a central location to store all the photographs, video and music which used to be stored across all of the other computers before.
So everything was fine until a few days ago, my main machine, which I use for software development didn't want to start again after I added some software and applied some updates. Needless to say, when I realised the computer wasn't going to start I just stared at it for a very long time, I was a little shocked since the last time I had a similar problem was a very long time ago.
So after trying the usual stuff, booting from a Windows XP cd, doing the repair option, executing chkdks, fixboot and fixmbr multiple times without success, I decided to just restore my computer using a backup from a night before using the Windows Home Server.
I downloaded the
Home Server restore cd files and then burned a blank cd with the contents of it. Then I went to boot from this cd and I was happy to see the Windows Vista like background showing me all of the network and hard drive drivers it found. This step is very important, if do not see any drivers for your network card, make sure you get them before trying to restore as you need to connect to the Home Server in your network to do this. If you don't have the network drivers, you can get them from your Home Server, just go to another computer with access to the Home Server, insert a USB drive and open one of the backups from the Home Server console, it needs to be one of the backups that belong to the computer you are restoring, once you open the backup file, you'll see a folder that has all the drivers in it. copy them to your USB drive and then go back to the computer being restored and upload these drivers. There is an option to search for drivers in a USB drive in the restore wizard, you won't miss it.
I did see the network drivers and all of my hard drives in this page so I just continued to the next step, the wizard asked me for the Home Server password, I typed it and then clicked on the next button. This is where I then realized that I should have tested the restoring option before, when all my computers where up and running to avoid surprises such as the one I got...well too late for that. The problem I encountered is the reason I am writing this blog and I hope someone with the same problem runs across this blog and finds the solution.
After I entered the Home Server password I received the following message:
"
An unknown network error has occured during PC Restore...Please verify that your network conntection is active and that your Windows Home Server is powered on."
Yikes! the first thing I did after that was restart my computer, boot from the cd and do it all over again... nothing, same error. I know that the connection existed since the wizard was able to see the home server, it showed me the name of it.
I tried restarting the Home Server, the computer to be restored, etc... no luck. Then, after searching for about an hour... I came across
this post that gave me the answer...
"Try disconnecting the network from the Internet and trying again; it's name resolution that's the problem."
Yes, I did that and it worked flawlessly, the restore took approximately two hours and then I was able to log on to Windows and all of my files and programs where there, like nothing had happened. The problem seems to be the way some ISPs and/or routers are configured, it causes a problem with the name resolution.
Lesson learned, if you are having the same problem and are receiving this error:
"
An unknown network error has occured during PC Restore...Please verify that your network connection is active and that your Windows Home Server is powered on."
Make sure your Home Server and affected computer can communicate, they need to be connected to the same switch, hub, etc... however, make sure that there is no connection to your cable modem or any other internet service, otherwise you might see this error and it will prevent you from restoring your PC.
Good luck!