Monday, February 10, 2014

MVC XHTML 1.0 Transitional "element is not supported XHTML"

While working with MVC 3 or MVC 4 applications I've noticed that some of my HTML tags show document validation warning messages such as "Element section is not supported".

This warning doesn't affect the rendering of the web page.  My first instinct was to Google the error.  There were solutions on the internet to removed or change the name of the ReflectedSchemas directory, but that didn't work for HTML5.  Plus, who wants to change the way Visual Studio does business, it would be best to configure the IDE for the appropriate environment instead of destroying its architecture.  Right!

THE SOLUTION:
When you create your MVC project with its appropriate HTML5 tags, you will get the validation warning message.

Do the following:

Make sure your document (_Layout) page is using HTML5 standards DocType declaration.


Set your Visual Studio to use HTML5
  1. Navigate to the Tools menu
  2. Options menu
  3. Choose the Text Editor node
  4. Choose the HTML node
  5. Select Validation
  6. Select HTML5 as the target
Warnings should immediately go away.

Monday, January 31, 2011

When bad coding goes wrong

While working with seasoned Java developer who was kicking his heals at ASP.NET MVC he ran into a problem encrypting the password across the url using a JQuery base64 plugin. The problem is he has too many variations of the JQuery file running within his project. He is not willing to resolve the issue, instead prefer to patch things. Unfortunately the base64 plugin continues to return a null exception.

Although I'm impressed by his coding methodology in some areas, I don't like the idea that he doesn't use standard practices when coding. 5 years ago I was new to C# and looked up to him for learning the correct way to code. I really thought I knew my stuff after 3 years. It wasn't until I went to a job interview, that I discovered that those practices were incorrect.

I recently enrolled in college and in my JAVA class many of my bad coding habits are reflected in the project assignment, resulting in point deductions. Well he continues to do things wrong, no comments in his code and so forth.

He sticks to what he knows and it often create problems in the future.

Like the time when he built a bunch of C# Web Services. When I looked at his code, I said that's going to run into security problems later, especially when Microsoft decides to send security patches. Although I expressed my concerns, 3 years later everything stopped working and he had to rewrite all of those Web Services again. Apparently, Microsoft did sent patches to close some holes in security and his Web Services were doing hatchet jobs to work. Going across servers, writing to files systems, SQL Queries and returning data.

THE GOOD, THE BAD, THE UGLY
He has been playing with MVC and Telerick controls for about 3 months. He is terrible with UI development, that's where I come in. I can do them both.

All the front facing apps the users log into use a custom login control that I built in ASP.NET C#. It is mobile and extensible. Simple add the web.config, login.aspx page and make a few changes to the Role name and it works out of the box.

He wanted me to use that control in a separate ASP.NET project, authenticate users and pass the authentication to his MVC project. UGLY HUH!

He is the senior developer, so I did what he asked. It would redirect them to the MVC project, but accessing the users profile or data was terrible. I said, let me build a project in MVC, use their Login page and get that to work with this project. He says, "OK, but I know nothing about the login stuff".

I completed the task in less than 1 hour and integrated it into his MVC project, fully functional.

He stripped the Registration page and put unconventional code into the page and says, I don't understand what fieldset, TextBoxFor(m => m.Username) or Html.BeginForm() and all that means. Removes everything and creates a table and puts stuff like this on the page:
Password
<%: Html.Password("password") %>

and a button: <button id="button1"<
Create a New Account

He adds a jQuery function to collect the data and passes that to a Controller
<script type="text/javascript">
$(document).ready(function () {
$('#button1').click(function (event) {
window.location = '<%= ResolveUrl("~/Account/Register2") %>' + '?UserName=' + $('#username').val() +
'&Password=' + Base64.encode($('#password').val() + "==");
})
});
</script>

The now here is the problem, people can see the password, so wanted me to encrypt the password. Here is what I did.

I created a method like this that takes a String as an argument and decodes the base64 url of the password and returns an unencrypted String of the password:

private String base64Converter(String password)
{
/* This method takes one argument password, decodes it and returns the decoded string */
// Bill King Added 1/31/2011
String pValue = "";
byte[] encodedDataAsBytes = System.Convert.FromBase64String(password);
string returnValue = System.Text.ASCIIEncoding.ASCII.GetString(encodedDataAsBytes);
pValue = returnValue.Substring(0, returnValue.Length - 2);
return pValue;
}

Below is his ActionResult in the controller that collects the button event:
public ActionResult Register2(string UserName, string Password, string ConfirmPassword)
{
Password = base64Converter(Password);
ConfirmPassword = base64Converter(ConfirmPassword);

This is the kind of lifestyle I need to change. I cannot get a job somewhere else making up stuff.


Tuesday, January 11, 2011

Visual Studio & Windows 7 IIS Configuration

Installing IIS and ASP.NET on Windows 7

Installing the ASP.NET component of IIS 7.0 in Windows Vista enables ASP.NET Web applications to run as local IIS Web sites. To enable Visual Studio to create and use local IIS Web sites, you must enable metabase compatibility. This lets Visual Studio interact with the IIS metabase and with the IIS 7.0 configuration store.

If IIS is enabled on your computer before you install the .NET Framework version 4, ASP.NET 4 is automatically registered with IIS. However, if IIS is not enabled on the computer when you install the .NET Framework, you must manually register ASP.NET with the appropriate version of IIS by running the ASP.NET IIS Registration tool. For more information, see ASP.NET IIS Registration Tool (Aspnet_regiis.exe).

Note Note

You must have administrative permissions to install IIS 7.0.

To enable ASP.NET on Windows Vista for debugging

  1. In , open Control Panel and then click Programs.

  2. Under Programs and Features, click Turn Windows features on or off.

    Note Note

    If Control Panel is set to display in Classic view, click Programs and Features, and

    in then in the left pane, click Turn Windows features on or off.

    The Windows Features dialog box is displayed.

    Note Note

    If User Account Control (UAC) is enabled, it might display a message when

    you try to access the Windows Features dialog box. Click Continue to access the

    dialog box. For more information, see User Account Control.

  3. Expand Internet Information Services.

  4. Expand Web Management Tools, expand IIS 6 Management Compatibility, and then select the IIS 6 Metabase and IIS 6 configuration compatibility check box.

  5. Expand World Wide Web Services, expand Application Development Features, and then select the ASP.NET check box.

    Note Note

    The options that are required for Web application development will

    automatically be selected.

  6. Expand World Wide Web Services, expand Security, and then select the Windows Authentication check box.

    To enable Visual Studio to debug applications, you must configure IIS 7.0 with the Windows Authentication module. By default, the module is not configured as part of IIS.

  7. Click OK to start the IIS and ASP.NET installation process.

  8. When the configuration process finishes, close Control Panel.

Monday, December 13, 2010

NOTES FROM THE WEEKEND: 12/10/2010 – 12/12/2010

THE C PROGRAMMING LANGUAGE

NOTES FROM THE WEEKEND: 12/10/2010 – 12/12/2010

Mobile Development environments:

Android

BREW

Symbian

Blackberry

Palm

Windows

iOS

Technologies:

C#

CSS3

Javascript

Perl

Java

Ajax

PHP

HTML5

Ruby

Python

Rails

This weekend I started studying the C language again. It’s not too different from C# except it isn’t object oriented. It’s procedural.

The thing that I found most important about the language is described in my writings here. The question that always played in my mind is how important is it to learn C again or to know it well.

I’m finding that Microsoft’s languages have not been the language of choice when it comes to changing the world. It has been C and other open source languages. Facebook, Google, jobs in those areas require knowledge in C.

Facebook is having a hacker contest and they stated that Microsoft Languages is not a consideration for the contest.

What I did on the weekend is wrote C on the windows platform and ported that code to the Linux and compiled it. ANSI C is the language of choice here and if we use Microsofts explicitly I run into compiler problems. There are libraries that MS has, which are not standard libraries in C. Which means, what I write become platform depended.

That’s currently the problem with porting applications from the .NET framework in Windows, to MAC, to Linux in the Mono world.

There are framework namespaces supported on windows not supported on other platforms. So I could develop for Windows and not be able to move that code to MAC or Linux without recoding the project.

ANSI C is the goal and purpose for me learning now. I’m going to continue this writing later, but want to port this information here to my journal.

Chat later.

Monday, December 6, 2010

Programming is not hard, we make it hard.

When I decided to write software as a career, one of the most difficult things about programming I personally discovered is being able to port knowledge from one language to the next or from one environment to the next.

Say, the C# language from building nothing but ASP.NET web sites to creating console apps, then moving from that to web forms. Many of the instructors I've listened too do not take a simple approach to explaining how to do that, which makes programming for a beginner extremely difficult.

Programming is not hard.
What makes learning to program difficult is that no one programmer thinks exactly alike. Although there are standards in programming and such. Every person approaches solving a problem differently. What is factored into solving the problem is the layer of knowledge that the person draws from to solve the problem.

If the problem requires the out put of data to the screen and the programmer has only built console applications, then they will most likely develop from that perspective. A web developer would choose a web interface and a Windows Form developer a desktop application.

When I teach courses to students learning to develop I tell them that it is best to purchase books from a single author on a particular language than to get them by title or subject only. Because each author will take a different approach to solving the same problem, the beginning programming may become confused.

Another problem with teaching programming languages is the learning curve. None of my instructors in college, or programming DVD or CD's I've purchased taught from a perspective that would shorten the learning curve. They simply taught. I would hear words like inheritance, delegates and my mind would go, I know these terms but what do they have to do with programming.

Teaching programming from a natural perspective will bring more people into the development world. Helping people make a connection between what they know already and what they are learning about programming will make programming fun and not mysterious.

Growing Interest in WebOS and .NET

I have some growing interest in WebOS and because of it have developed several paid applications for the mobile device.

Since HP and Palm have become one my interest have elevated to great enthusiasm. That excitement is leading me to think of other ways to use the environment, such as connecting it to my .NET development environment and porting over apps to it.

I think this can work.

Installing Windows Phone 7 on XP

My job purchased a number of Workstations for the few developers that we have. The machines are Dell's with 8 processors in them. The machines came pre-installed with windows Vista on them and instantly became a nightmare for running legacy applications and developing on.

Since the license purchase included Windows XP, I hit a button and XP was installed on the machine. The machines that followed came with XP pre-installed, thank God!

Anyway a few years have passed, the database Admin still has Vista on his machine and for a number of years was unable to get security updates from our WSUS server until we later purchased a license from Microsoft and upgraded.

I'm still running windows XP on my development machine and seem to run into problems developing for Windows Phone 7. Since Microsoft officially retired XP back in April of 2009 there is no support. I searched the Microsoft blogs and the Microsoft employees seem to be in a rage with those who are running XP and insist on getting support for Windows Phone 7 development on the OS.

One person on the web posted a solution and I am testing it to see if it works. Here is what they say:

Workaround for installing Windows Phone 7 CTP on Windows XP:

1.Download the Windows Phone Developer Tools CTP Refresh
2.Extract the contents of the setup package by running vm_web.exe /x and choosing a path to extract to
3.Go to the folder you extracted to in step 2 and open the file baseline.dat in notepad
4.Look for the section named [gencomp7788]
5.Change the value InstallOnLHS from 1 to 0
6.Change the value InstallOnWinXP from 1 to 0
7.Save and close baseline.dat
8.Run setup.exe /web from the folder you extracted to in step 2

What I did was right click on the vm_web.exe file I got from microsoft and extracted that into a folder.

I then right click and choose New > Text Document and opened that document.
I entered setup.exe /web in the first line and renamed the file setup.bat and double clicked the file to launch the install.

We will see if it works.