In my job that I’m in my last week of my employment I had to figure out somethings that seemed (to me anyway) to no longer be needed. What I needed to was to be able to debug a VB6 .dll in a Classic ASP website.
I was so used to the seamless why .Net does it that I had no idea where to start! The blog posts from the late 90′s were far and few between. And searching on “VB6.dll and debugging Classic ASP” didn’t return a lot of info.
What you will read below are the documents I left my employer. Hopefully this helps someone who has the task of debugging a legacy application on the web.
First setting up the Web Server:
Second the VB6 code:
If you get an error that states something like either of these:
Then what I did to fix this issue was to:
As a final step I always restarted the web server and I was then able to debug into the VB6 project from classic ASP. I know this information is 10 years old, but I still needed it. I’m guessing someone else will too.
Good Luck!
What is Public, Private, Internal, Protected (define them).
Answers:
If you have better answers, please leave a comment below (along with a decent explanation).
Tags: Mock Interviews, Review
My buddy and I in an effort to stay sharp have decided to try and do weekly mock interviews. Neither one of us know everything about coding and this is how we have decided to quiz ourselves in an effort to get outside of our comfort zone. There will be no judgement placed, the answers will not be “trick questions”, and the answers have to be legitimate with explanation (meaning you have to be able to answer it and have the other person understand it).
This is our first crack at it, so I’m sure tweaking of the process will happen after today. As you know I’m currently studying for the ASP.NET Web Developers exam (70-515) so I decided to ask questions from just chapter 1 of the book. I came up with 18 questions. There are 14 chapters in this book and I realized that by doing this, I am also reviewing the chapters from a different perspective. So each week I plan to do a couple of chapters for review and post it here.
ASP.NET 70-515
Questions:
1 – What is the protocol used to communicate between the web browser and the web server?
2 – What does the Request object represent
3 – What does the Response object represent
4 – Name the 5 Status Code Groups (hint: 404 as 4xx)
5 – Name 5 common Status Codes
6 – From within an ASP.NET page, you need to run a section of code only if the user has previously loaded the page and is submitting data as
part of a form. Which Page object property should you use?
7 – Where are solution files created by default?
8 – Which ASP.NET page model separates layout from code?
9 – Can you name the 7 different ASP.Net “special” folders?
10- What is the difference between ASP.NET Web Applications and ASP.NET Web Sites?
11- When is it best to use a Web Site versus a Web Application?
12- What are the 3 different modes you can use to create a Web Site?
13- What is the format of a configuration file?
14- If a setting exists in the root Web.config file and also in the Web.config file at the web application level but with a different value, which Web.config files takes precedence?
15- What is the name of the global configuration file?
16- What is the hierarchy of the ASP.NET configuration files?
17- You want to make a configuration setting change that will global to all web and windows applications on the current computer. What file do you change?
18- You want to make a configuration setting change that will affect only the current web application. What file do you change?
Answers:
1 - HTTP is a text based communication protocol that is used to request webpages from a web server and send responses back to a web browser.
2 – The Request object is used to represent the web browser’s communications to the web server.
3 – The communication from the web server back to the web browser is wrapped in the Response object.
4 – 1xx, 2xx,3xx,4xx,5xx
5 – 100: Continue 200: OK 201: Created 300:Multiple Choices
301: Moved Permanently 302: Found 400:Bad Request 401:Unauthorized 403:Forbidden 404:Not Found
407: Prox Authentication Required 408: Request Time-out 413: Request Entity Too Large
500:Internal Server Error 501: Not Implemented
6 – IsPostBack
7 – When a website is created Visual Studio creates a solution file (.sln) and a hidden solution user options file (.suo).
By default, these files are created in the My Documents\Visual Studio 2010\Projects folder for websites.
8 – The code-behind programming model separates user-interface layout markup from code.
9 – App_Browsers, App_Code, App_Global Resources, App_Local Resources, App_Themes, App_Web-References, Bin
10- For Web Applications:
- You can create MVC applications
- Visual Studio stores the list of files in a project file, rather than relying on the folder structure
- You cannot mix Visual Basic and C#
- You cannot edit code without stopping a debugging session.
- You can extablish dependencies between multiple web projects
- You must compile the application before deployment, which prevents you from testing a page if another page will not compile.
- You do not have to store the source code on the server.
- You can control the assembly name and version.
- You cannot edit individual files after deployment without recompiling
11- Web Sites are usually the right choice for one developer and Web Applications are best for enterprise environments.
12- File System, HTTP, FTP
13- XML
14- The Web.config file at the web application level takes precedence unless the setting has been configured to prevent overriding.
15- Machine.config
16- Global->Root->Website->Web App->Folder
17- Machine.config
18- Web.config in the root of the web application
Tags: ASP.NET, Mock Interviews, Review
I’ve been thinking for a while that I want to write a post about an architecture of websites using ONLY (90-95%) jQuery and web services. At my last job I was working on sites that were desktop like. Meaning, they had to be keyboard driven and basically function like a desktop. No refreshing of screens, modal windows, very dynamic grids and a lot of data.
When I found jQuery, I started to realize the power that it gave me over the screen. I could control ANYTHING I wanted with it. The problem was breaking the mold of using datagrids and very heavy and not very easily customizable Microsoft controls. Now I realize that these controls are reusable and that is their main benefit. However, how many times have you built a screen and spent hours trying to recreate something that is doable on the desktop that just was plain hard to recreate on the web? Plus then you had to deal with viewstate and the postbacks… To me it was just plain painful and ugly.
After playing with jQuery and asking multitudes of questions on StackOverflow, I found that using AJAX in jQuery allowed me to call web services. In all honesty, this was allowable in the old school way of AJAX using plain javaScript, however in jQuery you could also use JSON. Once I found that and figured out how nice JSON was to parse, I could create simple HTML tables that then utilized jQuery plugins for sorting. I could show and hide data based off of onclick events inside the table rows. It opened up a whole new possibility for creating desktop based apps on the web. I’m sure some will say that some of the web controls are good. And I agree, as there is no need to recreate the wheel for everything. However, when building my sites that used this model I usually had a couple of divs (as containers) and that is it. Everything else was in the .js files and the web services. Which was very clean and readable. Yes the .js files were intense but anyone who is familiar with javaScript could read it (and who isn’t really). The web services just got the data and returned it (as JSON). It was all very easy.
I found that the apps I created wowed the people I demoed them to, however, that isn’t enough for me to proclaim this is the way to go… I am the KING of the “KISS” methodology (Keep It Simple Stupid). I tend to over simplify things and sometimes I find later that the reason for the added complexity was for this reason or that reason.
My question to you is, why wouldn’t this model work? Where are the flaws in the design?
Tags: ajax, javascript, jQuery, JSON
As you know I am going to start my certification process. I have no idea how long it will take, but here is the path and the information that I found to become certified in .Net 4.0:
This is the Microsoft Link that describes the tests and the path: www.microsoft.com/learning/en/us/certification/cert-vstudio.aspx#tab2
It looks like MCTS is the foundation and then if you pass all of those, then you can do 1 more test and get the high end MCPD!
So 3 test for the MCTS:
Then plus this test for the MCPD:
A friend of mine told me about this site: www.learncertnow.com/Default.aspx. This site does video training. So if the book is tough, I may just try the video series to see if the information sinks in via video. However, it doesn’t look like this site has the tests I need to take yet. But I’m going to keep my eye out for them to see if it is another option in the future.
This is the 1st book I’m buying: www.amazon.com/MCTS-Self-Paced-Training-Exam-70-515/dp/0735627401/ref=sr_1_1?ie=UTF8&qid=1308082521&sr=8-1
I let you know how I progress once I get started. My plan is to buy the book in July!
Because of the edict that I ordered for myself, anytime I don’t know what something is, I’m going to research that topic. If it is something interesting and has some depth, I plan on writing a blog post about it. A few days ago, I saw a list items that one should be prepared to discuss as a C# programmer:
boxing/unboxing, generics, stack, and heap
Now I have done some coding in C# and I really do like it, but once again I find myself not having all the definitions and concepts that one would need to have a conversation about C#. So even though I have experience in C#, I sound like I don’t… I’ve seen this boxing/unboxing statement before. However, I had never seen it in the intellisense before, I figured it was a concept but I had no idea what it was.
I read some posts here and there but they were pretty confusing and didn’t break it down to the basic question of: why do I need to know what boxing and unboxing is?
Well today I think I found a good answer to that question. I have a C# book (“Visual C# 2005: The Language”) and I looked in the index if there was any reference to boxing or unboxing and I found this explaination of boxing on page 238:
…For integers, boxing occurs as items are added to the collection. Unboxing happens when items are accessed in the collection. Boxing occurs if a collection contains value types-integers are value types. Frequent boxing can prompt earlier garbage collection, which is especially expensive. The incremental penalty for boxing and unboxing can be substantial for a collection of value types. For a collection of reference types, there is the cost of down-casting, which is lighter…
OK, I realize that this explanation might be confusing as well. But the context was that the author was discussing Generic types in C#. In the book Generics types is a class with type parameters. The type parameter acts as a placeholder for a future type.
Come to find out that Generics and boxing/unboxing is all about performance. It is more efficient to have a Generic collection rather than a collection with a value type. Apparently if you populate a collection with value types then boxing is required which if you see the above definition causes the Garbage Collector to occur which is a performance hit.
I’m not going to lie to you, I’m just starting to wrap my head around this concept. The Generic type was introduced in .Net 2.0. You can read much more about Generics here. My use of Generics is light at best. However, in my next collection I will try to use a Generic type.
Just in case you are wondering, the concepts of Stack and Heap also relate to the Garbage Collector and types and performance. I got the following info from here:
I’m sure that there is way more info to these topics, but I hope that I broke down these concepts to a more simpler form. For me the simpler it is to understand the better, as I can then build on my simple explanation and get into more advanced topics and concepts.
If you find that you have a better definition, please leave me a comment and I will add it to this post.
Tags: C#, Summer of Progress, VB.NET
I’ll admit, I have a terrible memory especially when it relates to advanced topics in programming. I’ve been programming for many years and “just doing it” without saying, I need to “encapsulate this” or “abstract that”. I never cared that I didn’t know exactly what I was programming and why. I just got it to work and I was OK with that. However, this laziness hurt me a couple of times in various interviews and conversations with other programmers. It hurt my credibility and I lost out on some really cool jobs because I didn’t know definitions.
A few weeks ago I decided that I will remember the 4 principles of OOP. My friend Vince sent me a great link that really broke down the concepts in the most simplest form. The definitions found in this link are really high level, but perfect for an interview question asking “have you used OOP?” or “tell me about how you use OOP?” Since he sent me that link I have been going back to the site to not only memorize the definitions but also try to understand them.
This weekend when I refactored my code for GODSurfer.com, I found myself using all the principles of OOP (abstraction, encapsulation, inheritance, polymorphism). Not only was I using the principles, I knew which one to use and for which situation I should use them. I use abstraction and encapsulation every time I write an object so I won’t go over those 2, but for the 1st time I used inheritance and polymorphism in PHP.
I found that my super class that I had build (entry) was great for 90% of what I needed it for, however, there were certain types of “entries” that I needed to build exceptions into the entry object. The entry object is very basic:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | class entry { var $entryId; var $userId; var $entryTypeId; var $entryLinkId; var $entryText; var $entryVoteCount; var $entryTypeDescription; function __construct() { } function set_entryId($new_entryId) { $this->entryId = $new_entryId; } function get_entryId() { return $this->entryId; } ... } |
The entry object is very generic and works for the majority of types of entries that I need it for. However, I found that for 1 of the types I needed extra properties (categoryId, title and summary). So what I did was I created a sub class by using the extends function in PHP. Which basically is inheritance in PHP. My new object entryURL has all the properties and methods of the entry object but also allows me access to the properties that I need for this particular type of entry.
1 2 3 4 5 6 7 8 9 10 11 | class entryURL extends entry{ var $categoryId; var $title; var $summary; function set_categoryId($new_categoryId) { $this->categoryId = $new_categoryId; } function get_categoryId() { return $this->categoryId; } ... } |
The other principle I used for the sub class entryURL was polymorphism. I did this because I needed to add these new properties in the insert. In the entry object I did not have these properties so in the entryURL object I wrote an override method that includes those new properties.
*Overriding is when you redefine a method that has already been defined in a parent class (using the exact same signature).
1 2 3 4 5 6 7 8 9 10 11 12 | class entry { ... function insertEntry(){ $dbconnect = db_connect() or trigger_error("SQL", E_USER_ERROR); $myText = addslashes($this->entryText); $query = sprintf("INSERT INTO entry (typeId, linkId, userId, entryText, voteCount, active) ... |
1 2 3 4 5 6 7 8 9 10 11 12 | class entryURL extends entry{ ... function insertEntry(){ $dbconnect = db_connect() or trigger_error("SQL", E_USER_ERROR); $myText = addslashes($this->text); $query = sprintf("INSERT INTO entry (typeId, linkId, userId, entryText, voteCount, active, categoryId, title, URL) ... |
As you can see it is the same method, but just with the new values added to it.
So that is, 2 major principles in action (actually you saw all four in my examples). It actually wasn’t that difficult to grasp once I understood the definitions. So the Summer of Progress is moving right along!
Tags: Summer of Progress
I’ve decided to learn MVC. I recently started a new job, that may or may not allow me to use MVC. We will see. However, my plan is to learn it and create a soccer portal using MVC2 (or probably 3). I know MVC3 is out, however, the edition covering MVC3 was not out yet, and knowing how I am, I decided to purchase the Pro ASP.NET MVC 2 Framework by Steven Sanderson. It came highly recommend by Scott Hansleman so I purchased it.
I’ve been looking into ASP.Net hosts, since this idea of a soccer portal came to my mind. I am very familiar with hosting packages for php and mySQL (which are cheap). What I’ve found is that ASP.Net hosts can be reasonably priced as well, however, they don’t come with SQL Server Database (at least not what I’ve found). The cheap packages come with mySQL. Using mySQL is not a bad option, I’m used to mySQL with my php sites. .Net came out with a mySQL Connector that allows your ASP.NET applications connect to a mySQL database so we are all good right? Well… The book has examples using SQL Server not mySQL, so I made the decision that I would use mySQL since that will probably be the route I take (unless I find a cheap package with SQL Server).
So far, I’ve really enjoyed the book. It explains MVC2 very well. There are a lot of advanced concepts and terms that I’m not all that familiar with, however, he does a good job at explaining them. So the real meat and potatoes example starts on Chapter 4. Basically, he walks us through how to build an e-commerce website using MVC2. As of this post I ran into 2 problems with the examples and mySQL. The first problem I figured out thanks to some help from StackOverFlow.com, but the 2nd problem is still unsolved… I will update on the 2nd issue once an answer is found.
For now here was the 1st issue:
The connection string for mySQL is a little different than SQL Server. Now you may say; “Duh… I knew that”. Well I didn’t and here is what I ran into. In the Controller the very first part of the example was to hard code a connection string to the DB. Easy enough, this is what I put originally:
1 2 | string connString = "server=xx.xx.xxx.xxx;Database=db_SportsStore;User Id=dbUser;Pwd=xxxxxxxxx;Persist Security Info=True;"; productsRepository = new SportsStore.Domain.Concrete.SqlProductsRepository(connString); |
In the productsRepository it was set up like this:
1 2 3 4 | public SqlProductsRepository (string connectionString) { productsTable = (new DataContext(connectionSTring)).GetTable<Product>(); } |
When I ran that code I got the following error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server)
So… After looking at it, I thought maybe I need to look at an example of how a mySQL connectionstring differs. I pulled up an old project that I have started but never finished and found this (converted for this project):
1 2 3 4 5 6 | using MySql.Data.MySqlClient; string connString = "server=xx.xx.xxx.xxx;Database=db_SportsStore;User Id=dbUser;Pwd=xxxxxx;"; var connection = new MySqlConnection(connString); productsRepository = new SportsStore.Domain.Concrete.SqlProductsRepository(connection); |
Then the SqlProductsRepository was changed to this:
1 2 3 4 5 6 | public SqlProductsRepository(MySql.Data.MySqlClient.MySqlConnection connection) { connection.Open(); productsTable = (new DataContext(connection)).GetTable<Product>(); connection.Close(); } |
When I tried that I got another error:
{“You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘[t0].[ProductID], [t0].[Name], [t0].[Description], [t0].[Price], [t0].[Category]‘ at line 1″}
So, I felt I was getting closer, but still no luck. So once again StackOverflow.com came to my rescue. Thankfully it turned out to be a really easy fix… All I had to do to correct this issue was put the following in my connection string: SQL Server Mode=true;
1 | string connString = "server=xx.xx.xxx.xxx;Database=db_SportsStore;User Id=dbUser;Pwd=xxxxxx; SQL Server Mode=true;"; |
Once that was added, then everything functioned as expected. So there you go, issue 1 of 2 resolved. It shows that MVC2 and mySQL are compatible, now, issue #2 is more about LINQ to SQL. From what I understand originally LINQ to SQL didn’t support mySQL initially, so one of the statements in the book is causing an error. I have my question out on StackOverFlow. Maybe if the answer is interesting I’ll do another post, or maybe I’ll just add it to the end of this one. Right now, all I hope for is an answer.
If you ever need to loop through a table in javascript this is how I was able to navigate through one.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | var oTable = document.getElementById('myTable'); //gets table var rowLength = oTable.rows.length; //gets rows of table for (i = 0; i < rowLength - 2; i++){ //loops through rows var oCells = oTable.rows.item(i).cells; //gets cells of current row var cellLength = oCells.length; for(var j = 0; j < cellLength; j++){ //loops throug |