For this stage of development, I've rearranged the flow of the site. The user now arrives on the homepage in an anonymous state. They are presented with the option to log in via a button. Clicking the button will take them to a log in form. The form has a hard coded set of accounts that can be authenticated against. If the user authenticates successfully, then they are returned to the homepage, with new content shown to them as a fully authenticated user.
I've been following An Overview of Forms Authentication to help with this.
First of all, I've rearranged the homepage, so that it contains a user status and a button to allow them to login.
Following the 'Log in' button takes the user to a new log in page. For this, I've written some basic functionality that feeds back responses to the user based on their attempts to login using three hardcoded accounts.
When a log in is successful, the function FormsAuthentication.RedirectFromLoginPage is called. This creates a ticket, which marks the user as being logged in to the website. It then returns the user to the website's default page. The MSDN entry for this function explains how to defined which page the user is returned to.
Once the home/default page is reloaded, it can determine who is logged in and display some relevant information to them. In this example, I show the user their name, rather than a 'Logged Out' status if they are logged in. User.Identity.IsAuthenticated and User.Identity.Name allowed me to do this.
While implementing this, I had a problem with User.Identity.IsAuthenticated returning false, even though the user had been logged in. This was because I hadn't properly set Forms to be a valid authentication mode in the Web.Config. An answer on StackOverflow helped me figure out the problem.
This is a start to the authentication process. There's much more to do. For a start, allowing users to create their own accounts, which have a database to be stored in. Also, all of the user's data is currently being broadcast to the server in plain text, it'll be necessary to add some form of security encryption. Finally, the user will need to be able to log out their logged in account.
Friday, 21 November 2014
Wednesday, 19 November 2014
Creating text boxes for basic user account details using ASP.NET Web Forms
I'm still following Creating a Basic ASP.NET 4.5 Web Forms Page in Visual Studio 2013, which is taking me through creating a form, which the user can user to enter an email address and password in order to create an account.
I've expanded on the basic example to include two text boxes, which will output their contents to the adjacent labels when the user presses the 'Submit' button. In the code, I've grouped together the elements relating to the user's email address and the elements relating to the password. I've given the elements appropriate names, rather than the defaults:
Double clicking on an element in the Design view will generate a code stub to provide behaviour for that element. In this case, double clicking the Submit button created a stub that would execute when the button was clicked.
Following the example, I filled in script that outputs the value of the text boxes to the relevant labels.
Obfuscating the user's password as they enter it is a simple case of changing the TextMode property of the Text Box.
I've expanded on the basic example to include two text boxes, which will output their contents to the adjacent labels when the user presses the 'Submit' button. In the code, I've grouped together the elements relating to the user's email address and the elements relating to the password. I've given the elements appropriate names, rather than the defaults:
Double clicking on an element in the Design view will generate a code stub to provide behaviour for that element. In this case, double clicking the Submit button created a stub that would execute when the button was clicked.
Following the example, I filled in script that outputs the value of the text boxes to the relevant labels.
Obfuscating the user's password as they enter it is a simple case of changing the TextMode property of the Text Box.
Saturday, 15 November 2014
Creating a homepage using ASP.NET Web Forms
I've used the Creating a Basic ASP.NET 4.5 Web Forms Page in Visual Studio 2013 page on ASP.NET to follow a tutorial on creating a homepage. This gave me a simple page with a text field. Visual Studio has a handy WYSIWYG feature, which allows basic pages to be put together quickly.
The following image shows how the Design and Source tab shows the content differently:
It is possible to use the Design editor to make basic formatting changes, such as changing the font style and background colour.
The option to change the font was hidden in the Add/Remove buttons tab on the task bar.
The WYSIWYG has filled in some of the CSS and HTML code for the homepage for me:
The following image shows how the Design and Source tab shows the content differently:
It is possible to use the Design editor to make basic formatting changes, such as changing the font style and background colour.
The option to change the font was hidden in the Add/Remove buttons tab on the task bar.
The WYSIWYG has filled in some of the CSS and HTML code for the homepage for me:
Friday, 14 November 2014
Sprint 1
Using Visual Studio Online, I've been able to create a backlog of work and put the relevant items in to the initial sprint. I'm the sole developer on this project and my time is limited. I've figured that within a 2 week sprint I could likely spend no more than 11 hours working on this project.
The initial sprint will run from Friday 14th November to Friday 28th November.
I first added the initial backlog items. These cover the ability to view a homepage, allow the user to create an account and allow the administrator to view and delete accounts.
The time available for the initial sprint is taken up by creating the homepage and create account functionality. I have split these down in to tasks, with time allocated to both development and research, where I lack knowledge.
The initial sprint will run from Friday 14th November to Friday 28th November.
I first added the initial backlog items. These cover the ability to view a homepage, allow the user to create an account and allow the administrator to view and delete accounts.
The time available for the initial sprint is taken up by creating the homepage and create account functionality. I have split these down in to tasks, with time allocated to both development and research, where I lack knowledge.
Project Start
The aim of this project is to make a simple website with various common user interactions so that I may learn Microsoft's ASP. NET framework, using my existing knowledge of c#.
On this website, a user can create and share recipes with other users. They can create an account, submit recipes, view other users and their recipes, as well as being able to comment on and rate other recipes.
I have downloaded the .NET Framework and .NET SDKs from MSDN, along with the 2013 Express edition of Visual Studio.
I did this by clicking on the Get Started for Free link on the .Net Framework page on MSDN. I selected the option to get Visual Studio for Web.
As well as that, I have set up a Visual Studio Online account. This gives me free version control and repository and task management for up to 5 users.
I have installed Visual Studio 2013 and the .Net Framework, which took around 30 minutes.
Following the Share your code in TFVC page, I have created and committed an initial solution to the Visual Studio Online version control system.
On this website, a user can create and share recipes with other users. They can create an account, submit recipes, view other users and their recipes, as well as being able to comment on and rate other recipes.
I have downloaded the .NET Framework and .NET SDKs from MSDN, along with the 2013 Express edition of Visual Studio.
I did this by clicking on the Get Started for Free link on the .Net Framework page on MSDN. I selected the option to get Visual Studio for Web.
As well as that, I have set up a Visual Studio Online account. This gives me free version control and repository and task management for up to 5 users.
I have installed Visual Studio 2013 and the .Net Framework, which took around 30 minutes.
Following the Share your code in TFVC page, I have created and committed an initial solution to the Visual Studio Online version control system.
Subscribe to:
Posts (Atom)










