Posts

Showing posts with the label Dina's Pet Project

User Login, Create User, Send Password close to done

Image
The basics for the login pages are done. A few more tweaks and that will be done. It might seem like I take forever but in truth, I don't have many hours a week to give to this pet project right now. I hope to have more time this fall.  

New SQL security finds web.config hole

Image
Yesterday, I was reading the MSDN FLASH email newsletter and saw a listing for another SQL injection article. Since one of Wayne's sites was recently hacked, I thought I would read it. The article is clear and gives explicit steps to take. Since I had only done one of the three things (SQL stored procs), I thought I would mess with the last one: execute permissions only. Wayne pointed me to a stored proc to grant permissions to a user. Since users and roles are one of those areas that after you have them set up correctly, you don't mess with them, I stumbled my way through creating a user. I ran the stored proc (which will have to be run after every .netTiers generation), modified my sql connection in web.config and tried my pet project site. I get an error about SELECT statements and permissions. .netTiers was supposed to be configured in web.config to use stored procs but apparently not. So I change the file, build, and still get the error. Someone, somewhere is...

Time goes on

Image
There are a few times in my life when a project phase just goes on forever. Back in my Microsoft days, I hated the last stages of the ship cycle. People were burned out, higher-ups were already on to the next phase. Front-line devs, testers, pms, and writers were either too burned out to function or too hyped up to listen. The mid-level guys were running interference every which way. The bell-curve was watched and the marketing dicks were breathing down everyone's throat and lord help you if you broke the build. I was thrilled when my boss finally made the rounds to ask if I thought the product was ready to ship. He asked everyone personally instead of some meeting where the team bully could badger me into saying something I would regret. And here I am with my own project in the end of one of the first phases and I trudge on. I'm not near enough done. No ship award in my near future.

Exception Handling for NetTiers

Image
I'm still cleaning up code. One of the things that has never worked in NetTiers is the Microsoft Enterprise Library Exception Handling. I would get an exception thrown in the NetTiers code and the line was an exception with no data. I would get the error on a SQL insert via the NetTiers layers but no information about what was wrong with the data. Since I'm using the Insert where the param is the base type such as    userService.Insert(newUser); I knew that datatyping from a C#/.Net perspective wasn't the problem. I knew it was at a SQL level but I didn't know what it could be. So I finally had to fix the .NetTiers ExceptionHandling. I'm not sure why doesn't work right off the bat like the rest of NetTiers but I also didn't care enough to investigate. Once I get the ExceptionHandling working, I don't ever touch so I haven't had to REALLY understand it. But now it has to work, it's hard to move forward without inserting data on this particular ...

Get the mop out: code cleanup

Image
Now that I have 90% of the v1 features for my pet project web site decided, and have a bullet-proof process for new tables, custom procs and other stuff NetTiers handles, I'm cleaning up the code. I'm ripping out any code I wrote to go against the SQL server that NetTiers handles for me. I'm cleaning up all gridview and codebehind to be consistent with naming and usage. I'm removing files that were tests to see how I wanted something to work. I'm removing links and cleaning up the masters. Wayne suggested I change a feature from random choice to numeric order choice so that a progression was predectible. I've been fighting it but he finally gave me a business logic reason. Ok, so now I'm changing SQL table column data types. That dominos into all sorts of changes. Once all this gets back to working, I'll start on the visual design. I haven't written themes and skins so I'm going to try to grab a working set that is close to my overall design. I...

New Code to AJAX

Image
My pet project is a new website. I'm working on the search page which searches through several NetTiers Services in the Component layer. It took me a few hours to figure out exactly what I wanted to do here. Do I user an Object Data Source? User StringBuilder to return an HTML table? What should the gridview link to once the search has been performed? Then I thought, I know I'm just going to AJAX this code. Am I just wasting my time? I just want to get v1 out the door. AJAX can wait to v2 but then I think none of this code would be used via AJAX except the NetTiers stuff. Do you design new websites via AJAX right off the bat? I haven't done enough AJAX to be able to think AJAX as a first pass on the design.

NetTiers Find method

Image
NetTiers will build methods for normal CRUD as well as anything they can determine. For example, if you have a table with 1PK and 2FKs, the template with build a method for select where the IN params are the two FKs. Great! I probably need that. But things get a little weird when I need to search. For example, I have a user's table and I want to be able to return results for all users that are like a searchterm. How about all user's like Dina. In T-SQL, I usually would have a where clause " UserName like '%@UserName%'. Works for me. NetTiers has a Find method for each table. When creating a find proc, it's hard to determine which columns you would want to search through. NetTiers discovery does a bit of assuming that the first column (after the PK/FK columns) is THE main data column (such as a name). But that takes some forethought in terms of table creation. The NetTiers find method comes in two varieties: one with sql params in the NetTiers format and one wi...

.Net SiteMap using Sql Provider - change to handle role trimming

Image
My site has two roles: Admin, SecureUser, and three types of content:Admin, SecureUser, Public. I found that the code in the last post  from Jeff Prosise wasn't managing roles in the SiteMap. For a visitor to the site that has not logged on (anon), the site map improperly showed Admin and Public pages. I checked the web.config and the SQL statement so it had to be either the database caching or the sql provider for sitemaps. I google'd and found several posts in 2006 about this but none since so I knew it had to have been resolved. I found this blog  post by Ishai Hachlili that had the code to deal with roles correctly. I added the code and the problem went away. I'm not sure the code is robust enough to handle a large site but it fixed the problem for now. As an aside, several of the 2006 posts said to just fix the web.config by making sure the <location> tags were correct. This meant any user could see links for the site that were restricted but would be d...

.Net SiteMap using Sql Provider

Image
I stared working on my sitemap tonight. Never done the SiteMap stuff before. Opened my Pro ASP.NET 2.0 in C# 2005 that I use as a jump off point for intro topics I haven't touched yet. The chapter is great but I like my data in the database which gets backed up every night. I understood enough and even got a test page up using nested site map files. Hurray! Now on to the SQL provider. I knew there had to be one so I googled and found an article with code by Jeff Prosise. The article covers the .cs file that is the SQL provider, as well as the web.config changes, the T-SQL, and the aspnet_regsql commands. After you get the provider up and working, don't expect the SQL provider to show up in the Data Source Configuration Wizard: You'll have the change the SiteMapDataSource to specify the Provider that you added to the web.config for SQL: < asp : SiteMapDataSource ID ="TotalSiteMap" runat ="server" SiteMapProvider ="AspNetSqlSiteMapProvid...

OOP: Properties and UserProperties

Image
The Problem I want to show a page with all the user-settable properties. Any properties that the user hasn't set should be shown but the value should be empty or null or some nice text indicating such. However, what is the BEST way to design this? The Tables I have a [Properties] table. I have a [UserProperties] table that has a FK back to [Properties]. There is only a row in the [UserProperties] table is the user has set one. If not set, no row. So back to what I want to show: in the user's account area, a page of all properties where any properties that have been set show that value, otherwise some text indicating the property has not been set. I'm going to go through every option to go from DB design to .Net code for the page that Wayne and I discussed on this fine rainy, sunny day. All SQL Most obvious from a database perspective: T-SQL join (1 db call) that includes all properties so depending on how it is written, right or left join. The problems with...

Code Cleanup unveals bugs

Image
I love it when I'm just cleaning up some code after some major changes and I discover code that has been sitting there a while that would never have worked. I don't even have to run/test it. I can read it and know it's broken. So is that a win for finding a bug and fixing it before it showed up or is that WTF? for having such an obvious bug in the first place.

CodeSmith NetTiers discovery of a custom stored procedure

Image
I have a table with two FKs. NetTiers creates a stored proc for the PK as well as a stored proc for each FK however it doesn't create a stored proc that uses both FKs as the IN params. So I need to create this in a way that NetTiers can discover it and build the code objects to support it. First I have to create the stored proc with a discoverable name. This requires several settings in the NetTiers template. First, that I want custom stored procs discovered so IncludeCustoms =true. Second, I want any stored procs to have a naming prefix so ProcedurePrefix =usp. Third, I need to handle the actual name of the stored proc. NetTiers uses discovery based on a template where the zeroth parm is the table name and the first parm is the Procedure Prefix so CustomProcedureStartsWith ={1}_cust_{0}_. The remainder of the stored proc name is irrelevant but what is returned is very important. I usually return all columns which is NetTiers default object handling. If I choose not to include all...

How do you GridView?

Image
I've been stuck in build hell for a week but now back to code. I want data that would normally be a JOIN between two tables. It's a join between ProfileProperties and UserProfileValues. But since I'm using NetTiers for my middle tier and I just want to get going, I'm writing a subpar GridView. The first column is pulled from a select of all profile properties provided by my ProfileDataSourceObject given to me by NetTiers. The second column is a function with a param of the profile property. The function grabs the user from the context and the profile property from the param, then determines what (if any) value has been set. This is not how I should do things. And since I usually don't do it this way, I'm sort of having to relearn some aspx syntax on how to do this. I much prefer to have SQL return this data and just format it in the GridView. SQL doesn't change everytime Microsoft releases a new version of Visual Studio. How would you do this?  

More NetTiers configuration

Image
Building Separately Building the NetTiers projects are getting tedious inside my main web app solution. I'm now building them separately and just moving into my main solution as references to each project. While I'm making so many database design changes, that is the best option. When the table designs and relationships are in place, I may move the .NetTiers projects back into my main solution. Table Standards One of my tables had the 'name' column as the last column as opposed to the column immediately following all the id,pk,fk columns. NetTiers decided only the next column after the id,pk,fk must be the most meaningful. It used this column which was not the name column but some non-determining column as the value for drop down lists in it's web admin site. So for everytable who had this table as a fk, this non-determining column populated as drop down list. So I had to change that in the database then regenerate the NetTiers projects. NetTiers Admin site not ...

ID ten T error (ID10T): Check the data

Image
I finally got NetTiers up and running and wanted to see my data. I choose the last data table I designed. I just spent an hour trying to use NetTiers to see my data with their version of a DataSource for that table. I finally figured out the table has nothing to see. Ugh!!!   The last hiccups were web.config issues. Easily found answer on google.   So NetTiers templates are configured. NetTiers projects are integrated into my solution with several other projects. Everything builds. I can call the highest level web and data NetTiers objects. Now time to check in to source control. I'm checking in entire NetTiers template tree, all generated files from the templates, and all changes to my web app so that I can use NetTiers. I don't build directly into my project tree so I have to copy the generated files over. This is a failsafe for now that I expect to eventually remove. I already have a change to a table to make so I'll figure out how I want that process to go. ...

Source Safe Control from Visual Studio 2005

Image
Apparently, Source Safe and Visual Studio have to have the projects as sibling nodes both on the hard drive and in source safe. The source safe names must match the Visual Studio project names. So after dinking with both to try to get them to talk to each other, I scraped my current visual studio node and reorganized my hard drive directories so that all projects are siblings and the solution files are in the parent directory. Then I tried to tie Visual Studio to Source Safe by hand. Since it still didn't work, I renamed my visual studio parent node just to save it instead of deleting. Then I had the Visual Studio solution add all the projects to source safe. This is definitely not the recommended method but everything is still small. One of these days, I just code. And code. And code.    

NetTiers Template Integration with Existing Solution

Image
I've been working for two hours to get my existing NetTiers CodeSmith Template to generate the files the way I need them. The NetTiers template gets 90% there out of the box but the template tips for each line item are sometimes obsure or require another lineitem to be TRUE. Then there is a fair bit of user error such as what to name the libraries created by the template, the directory they should be sent to. One error right out of the box is the LibraryPath value. It's inconviently stuffed in the Advanced CRUD section and just says Reference. After the projects try to build but fail but to the reference libraries not found, I figured out what was going on. NetTiers generates the web service and client pieces which I keep in the template but don't use. No I'm working on making sure my project library which includes all the libraries built by NetTiers CodeSmith has the right hierarchy in terms of having functions where I would expect them to be. I'm sure at some p...

Dina's Pet Project Summary

Image
So where am I with my Pet Project?   the domain name(several really) purchased domain names linked to the web server email entries set up new virtual development server (Thanks Wayne) VS2005 web project with a middle layer library SQL Server database for project SQL Server database for bugtracker/issue mgmt CodeSmith .NetTier with a template close to what I need basic but ugly functionality using Microsoft Membership, Roles (Profiles are home grown)