This document provides a tutorial with 15 exercises to teach how to create a basic ASP.Net web application with user authentication and authorization. The exercises guide the user to create web forms, configure authentication using web.config files, add a login page that authenticates against a SQL database, and customize the user experience including remembering user logins.
Overview of ASP.NET
An ASP.NET Page
Server Controls
User Controls
Validation
Master Pages
Themes & skins
Page Cycle Events
Menu, Navigation & Sitemaps
Some cool new ASP.NET 2 Server Controls
Overview of ASP.NET
An ASP.NET Page
Server Controls
User Controls
Validation
Master Pages
Themes & skins
Page Cycle Events
Menu, Navigation & Sitemaps
Some cool new ASP.NET 2 Server Controls
.net training | learn .net | Microsoft dot net Course | Microsoft dot net onl...Nancy Thomas
Website : http://www.todaycourses.com
.Net Online Training Concepts :
NET FUNDAMENTALS
Why .NET?
The .NET initiative
Introduction to .NET framework
Advantages of .NET framework
System requirements
.NET FUNDAMENTALS
Why .NET?
The .NET initiative
Introduction to .NET framework
Advantages of .NET framework
System requirements
INTRODUCTION TO VISUAL STUDIO .NET
Base class libraries
Common language-runtime (CLR)
Microsoft intermediate language (MSIL)
Optimized just-in-time (JIT)
Common type systems (CTS)
Common language specification (CLS)
Compilation and execution of .NET application
Assemblies
Namespace
JavaScript and jQuery for SharePoint DevelopersRob Windsor
If you’re a SharePoint developer you either are doing JavaScript development now or you will be doing JavaScript development in the near future. There has been an increased focus on client-side development with each of the recent versions of SharePoint and now, with the introduction of the SharePoint 2013 App model, understanding client-side development is a must. In this session, we`ll look at JavaScript development from a SharePoint perspective. In addition to effective use of JavaScript and jQuery in your applications, we`ll look where you can deploy JavaScript files and how to reference those files in your pages and web parts.
.net training | learn .net | Microsoft dot net Course | Microsoft dot net onl...Nancy Thomas
Website : http://www.todaycourses.com
.Net Online Training Concepts :
NET FUNDAMENTALS
Why .NET?
The .NET initiative
Introduction to .NET framework
Advantages of .NET framework
System requirements
.NET FUNDAMENTALS
Why .NET?
The .NET initiative
Introduction to .NET framework
Advantages of .NET framework
System requirements
INTRODUCTION TO VISUAL STUDIO .NET
Base class libraries
Common language-runtime (CLR)
Microsoft intermediate language (MSIL)
Optimized just-in-time (JIT)
Common type systems (CTS)
Common language specification (CLS)
Compilation and execution of .NET application
Assemblies
Namespace
JavaScript and jQuery for SharePoint DevelopersRob Windsor
If you’re a SharePoint developer you either are doing JavaScript development now or you will be doing JavaScript development in the near future. There has been an increased focus on client-side development with each of the recent versions of SharePoint and now, with the introduction of the SharePoint 2013 App model, understanding client-side development is a must. In this session, we`ll look at JavaScript development from a SharePoint perspective. In addition to effective use of JavaScript and jQuery in your applications, we`ll look where you can deploy JavaScript files and how to reference those files in your pages and web parts.
This presentation emphasis on How to connect a Play Application with Mysql as database in Scala.Play includes a simple data access layer called Anorm that uses plain SQL to interact with the database and provides an API to parse and transform the resulting datasets.
Python Code Camp (Professionals) is a whole day workshop that aims to enable professionals to learn Python Basics and Django.
Visit: http://devcon.ph/events/python-code-camp-professionals-2016
The complete ASP.NET (IIS) Tutorial with code example in power point slide showSubhas Malik
SP.NET is a server-side Web application framework designed for Web development to produce dynamic Web pages. It was developed by Microsoft to allow programmers to build dynamic web sites, web applications and web services. It was first released in January 2002 with version 1.0 of the .NET Framework, and is the successor to Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common Language Runtime (CLR), allowing programmers to write ASP.NET code using any supported .NET language. The ASP.NET SOAP extension framework allows ASP.NET components to process SOAP messages.
Full credit to Microsoft but i have modified and updated the presentation to increase readability and simplicity. Hope you will enjoy knowing about Session Mgmt.
Traditional marketing is declining as digital strategies take over. The rise of technology has made interruption-based marketing obsolete. A historical review shows the evolution of marketing from print to digital. Digital marketing now dominates with personalized strategies and consumer engagement. To thrive, businesses must invest in SEO, social media, big data, and valuable content.
Often young people dream and think about entrepreneurship as a short cut way of being rich and get famous and when challenges start coming in their entrepreneurial journey, they simply quit in between the great expedition. I believe, Social network and digital media channels directly responsible for creating the negative influence of overnight success. Many young entrepreneurs are still missing the right direction because of unaware of dark side of being an entrepreneur.So what it takes to be an Entrepreneur?
Business Intelligence is a collection of technologies, applications, processes and practices for the transformation of business data into business useful information. A business intelligence solution helps to transform raw data into actionable information which helps support business decision making.
Mobile Device: Trend, Growth and Future ProspectVivek K. Singh
Report on impact of mobile devices on businesses and learn about mobile usage statistic, mobile marketing, Mobile phone users worldwide, Mobile technology, Mobile app usages, Mobile Internet Access, Mobile devices statistics, Mobile App Statistics and Mobile Marketing Facts & Statistics that are affecting consumer behaviors and driving sales around the world.
Black Sea and CIS Countries Business cycleVivek K. Singh
The recurring and fluctuating levels of economic activity that an economy experiences over a long period of time. The five stages of the business cycle are growth (expansion), peak, recession (contraction), trough and recovery. At one time, business cycles were thought to be extremely regular, with predictable duration, but today they are widely believed to be irregular, varying in frequency, magnitude and duration.
For detail information visit: http://goo.gl/5ITbX
An intranet is the application of Internet technology, more specifically World Wide Web technology within the organizational boundary. The very same technology is applies (Web servers, browsers, protocols etc.), but access is restricted exclusively to organizational members for example by means of "firewalls" or physically separating the intranet from external network ("firebreaks").
SMEs development for Georgia is a primary concern to become self-reliant and fight with unemployment and poverty in the country. Georgia is basically SMEs economy but there is a need of redefining its SME sector operating framework. Non availability of information, lack of entrepreneurship and technological backwardness are the principal problem for SMEs development in the country and required communication framework for resolve these problems.
Let's dive deeper into the world of ODC! Ricardo Alves (OutSystems) will join us to tell all about the new Data Fabric. After that, Sezen de Bruijn (OutSystems) will get into the details on how to best design a sturdy architecture within ODC.
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
The field of Information retrieval (IR) is currently undergoing a transformative shift, at least partly due to the emerging applications of generative AI to information access. In this talk, we will deliberate on the sociotechnical implications of generative AI for information access. We will argue that there is both a critical necessity and an exciting opportunity for the IR community to re-center our research agendas on societal needs while dismantling the artificial separation between the work on fairness, accountability, transparency, and ethics in IR and the rest of IR research. Instead of adopting a reactionary strategy of trying to mitigate potential social harms from emerging technologies, the community should aim to proactively set the research agenda for the kinds of systems we should build inspired by diverse explicitly stated sociotechnical imaginaries. The sociotechnical imaginaries that underpin the design and development of information access technologies needs to be explicitly articulated, and we need to develop theories of change in context of these diverse perspectives. Our guiding future imaginaries must be informed by other academic fields, such as democratic theory and critical theory, and should be co-developed with social science scholars, legal scholars, civil rights and social justice activists, and artists, among others.
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Tutorial asp.net
1. Tutorial: ASP.Net for Master of Computer
Application Students
Prepared by Vivek Kumar Singh
Exercise 1: Create PublicPage.aspx
Use Notepad or the text editor of your choice to create a text file named PublicPage.aspx in
your PC’s Inetpubwwwroot directory. Then add the following text to create a simple Web
form:
<html>
<body>
<h1>Public Page</h1>
<hr>
<form runat="server">
<asp:Button Text="View Secret Message"
OnClick="OnViewSecret" RunAt="server" />
</form>
</body>
</html>
<script language="C#" runat="server">
void OnViewSecret (Object sender, EventArgs e)
{
Response.Redirect ("Secret/ProtectedPage.aspx");
}
</script>
Exercise 2: Create ProtectedPage.aspx
Create a new directory named Secret in Inetpubwwwroot. In it, create a text file named
ProtectedPage.aspx and enter the following code:
<html>
<body>
<h1>Protected Page</h1>
<hr>
<br>
Be careful investing your money in dot-coms.
</body>
</html>
Exercise 3: Test
Test what you’ve done so far by opening PublicPage.aspx in your browser and clicking the
“View Secret Message” button. In response, ProtectedPage.aspx should be loaded and should
display a secret message for you.
Exercise 4: Create Web.config
Create a text file named Web.config in Inetpubwwwroot and enter the following statements:
<configuration>
<system.web>
<authentication mode="Forms">
2. <forms loginUrl="LoginPage.aspx">
<credentials passwordFormat="Clear">
<user name="Jeff" password="hawkeye" />
<user name="John" password="redrover" />
</credentials>
</forms>
</authentication>
<authorization>
<allow users="?" />
</authorization>
</system.web>
</configuration>
The <authentication> section of this configuration file enables forms authentication,
designates LoginPage.aspx as the page that users must go through to get to protected
resources, and defines two sets of login credentials. The <authorization> section grants
anonymous users access to all parts of this site that don’t specify otherwise.
Exercise 5: Create LoginPage.aspx
Create a text file named LoginPage.aspx in Inetpubwwwroot and enter the following
statements:
<html>
<body>
<h1>Please Log In</h1>
<hr>
<form runat="server">
<table cellpadding="8">
<tr>
<td>
User Name:
</td>
<td>
<asp:TextBox ID="UserName" RunAt="server" />
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<asp:TextBox ID="Password" RunAt="server" />
</td>
</tr>
<tr>
<td>
<asp:Button Text="Submit" OnClick="OnSubmit" RunAt="server" />
</td>
<td>
</td>
</tr>
</table>
</form>
<hr>
<h3><asp:Label ID="Output" RunAt="server" /></h3>
</body>
</html>
<script language="C#" runat="server">
void OnSubmit (Object sender, EventArgs e)
3. {
if (FormsAuthentication.Authenticate (UserName.Text, Password.Text))
FormsAuthentication.RedirectFromLoginPage (UserName.Text, false);
else
Output.Text = "Invalid login";
}
</script>
This page displays a simple login form that accepts a user name and password. Clicking the
Submit button activates OnSubmit, which uses the Authenticate method of the
FormsAuthentication class (a member of the .NET Framework Class Library’s
System.Web.Security namespace) to authenticate the supplied user name and password
against the credentials defined in the <credentials> section of Web.config. If the login is
approved, FormsAuthentication.RedirectFromLoginPage is called to send the user to the page
protected by the login page.
Exercise 6: Test
Verify that the application still works as it did before by opening PublicPage.aspx again and
clicking the “View Secret Message” button. Because you’ve yet to restrict access to
ProtectedPage.aspx, the secret message should appear in the browser window.
Exercise 7: Create another Web.config file
Create another text file named Web.config, this time in the Secret directory
(Inetpubwwwrootsecret). Add the following statements to deny anonymous users access to
files in this directory:
<configuration>
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</configuration>
Exercise 8: Test
Repeat the test you performed in Exercise 6 and verify that clicking the “View Secret Message”
button causes your login page to appear (see below). Type “Jeff” into the User Name box and
“imbatman” into the Password box. Then click Submit. Does the secret message appear? Why
or why not? Finish up by entering the user name “Jeff” and the password “hawkeye.” Do you
see ProtectedPage.aspx this time?
4. Exercise 9: Modify the top-level Web.config file
Close Internet Explorer and reopen it (important!). Then delete the <credentials> section from
the top-level Web.config file—the one in Inetpubwwwroot. Test the application again by
clicking the “View Secret Message” button. Can you get past the login page?
Exercise 10: Create an authentication database
While it’s perfectly possible to secure ASP.NET applications using credentials stored in
Web.config, doing so isn’t very realistic unless you plan to authorize access to only a small
number of users. In the real world, it makes sense to store authentication data in a database,
and to write the login page so that it authenticates against the database rather than against
Web.config.
To that end, open a command prompt window, go to the folder where Weblogin.sql is stored,
and type
osql –U sa –P –i weblogin.sql
This command executes the script found in Weblogin.sql, which creates a new SQL Server
database named WebLogin. Inside the database is a table named Credentials that contains the
following records:
UserName Password
Jeff hawkeye
John redrover
5. Before proceeding, use the SQL Server Query Analyzer (or the tool of your choice) to verify
that the database was properly created and initialized.
Note: Weblogin.sql assumes that SQL Server is installed on drive C: on your PC. If you
installed SQL Server on a different drive, open Weblogin.sql and edit the statement
FILENAME = 'C:program files...weblogin.mdf'
to include the correct drive letter.
Exercise 11: Add a CustomAuthenticate method and modify OnSubmit
Add the following statements to the top of LoginPage.aspx:
<%@ Import NameSpace="System.Data" %>
<%@ Import NameSpace="System.Data.SqlClient" %>
Then add the following method to the <script> block:
bool CustomAuthenticate (string username, string password)
{
SqlDataAdapter adapter =
new SqlDataAdapter ("select password from credentials " +
"where username = '" + username + "'",
"server=localhost;uid=sa;pwd=;database=weblogin");
DataSet ds = new DataSet ();
adapter.Fill (ds);
DataTable table = ds.Tables[0];
foreach (DataRow row in table.Rows) {
string pw = row[0].ToString ().TrimEnd (new char[] { ' ' });
if (String.Compare (password, pw, false) == 0)
return true;
}
return false;
}
Finally, modify the OnSubmit method so that it calls CustomAuthenticate instead of
FormsAuthentication.Authenticate:
void OnSubmit (Object sender, EventArgs e)
{
if (CustomAuthenticate (UserName.Text, Password.Text))
FormsAuthentication.RedirectFromLoginPage (UserName.Text, false);
else
Output.Text = "Invalid login";
}
CustomAuthenticate uses ADO.NET to perform a database query and validate the user name
and password provided to it.
Exercise 12: Test
Restart your browser again. Then test the application again by clicking the “View Secret
6. Message” button and entering one of the sets of credentials included in the WebLogin
database. Verify that you can once more get to ProtectedPage.aspx.
Exercise 13: Try This
Go back to PublicPage.aspx in your browser and click “View Secret Message” again. Verify that
you go straight to ProtectedPage.aspx without having to enter a user name and password
again.
Now close your browser and restart it. Open PublicPage.aspx and click the “View Secret
Message” button. Because the authentication cookie issued to you when you logged in was a
temporary one, you’ll have to log in again to get to the protected page.
Exercise 14: Make the authentication cookie persistent
When you pass FormsAuthentication.RedirectFromLoginPage a second parameter that equals
false, like this:
FormsAuthentication.RedirectFromLoginPage (UserName.Text, false);
RedirectFromLoginPage issues a temporary cookie, or session cookie, that expires when the
browser is closed. If you pass true instead, RedirectFromLoginPage issues a persistent cookie
that’s good for 50 years. Demonstrate by doing the following:
1. Change RedirectFromLoginPage’s second parameter to true.
2. Restart your browser and open PublicPage.aspx.
3. Click the “View Secret Message” button and log in.
4. Verify that the secret message is displayed.
5. Close your browser.
6. Restart the browser, open PublicPage.aspx, and click “View Secret Message.”
Because the cookie is now being cached on your hard disk, you shouldn’t have to log in again
in step 6. Finish up by doing the following:
1. Use Internet Explorer’s Tools/Internet Options/General/Delete Cookies command to
delete all the cookies on your PC.
2. Open PublicPage.aspx and click “View Secret Message.”
This time, you will have to log in because when you deleted the cookies on your PC, you
deleted the authentication cookie, too.
Exercise 15: Let the user decide
Add a “Remember me” check box to LoginPage.aspx that lets the user decide whether to make
the authentication cookie persistent (if the box is checked) or temporary (if the box isn’t
checked), as shown below.
7. To add the check box, modify the form as follows:
<form runat="server">
<table cellpadding="8">
<tr>
<td>
User Name:
</td>
<td>
<asp:TextBox ID="UserName" RunAt="server" />
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<asp:TextBox ID="Password" RunAt="server" />
</td>
</tr>
<tr>
<td>
<asp:Button Text="Submit" OnClick="OnSubmit"RunAt="server" />
</td>
<td>
<asp:CheckBox Text="Remember me" ID="RememberMe" RunAt="server" />
</td>
</tr>
</table>
</form>
8. And, so that the check box will be honored, change the second parameter passed to
RedirectFromLoginPage to RememberMe.Checked:
FormsAuthentication.RedirectFromLoginPage (UserName.Text,
RememberMe.Checked);
Checked is a CheckBox property that indicates whether the box is checked (true) or unchecked
(false).
Exercise 16: Test
Test the changes you made in Exercise 15 by verifying that:
1. If the “Remember me” button isn’t checked and you restart your browser, you have to
log in again to view ProtectedPage.aspx.
2. If the “Remember me” button is checked and you restart your browser, you don’t have
to log in again to view ProtectedPage.aspx.
Exercise 17: Personalize the secret message
Modify ProtectedPage.aspx so that it prefaces the secret message with the user’s login name.
Here’s the modified file, with changes highlighted in bold:
<%@ Page Language="C#" %>
<html>
<body>
<h1>Protected Page</h1>
<hr><br>
<% Response.Write (Context.User.Identity.Name + ": "); %>
Be careful investing your money in dot-coms.
</body>
</html>
Exercise 18: Change the cookie’s expiration date
Modify OnSubmit so that if “Remember me” is checked, the authentication cookie that’s issued
has a lifetime of 7 days instead of 50 years. The key is to replace the call to
RedirectFromLoginPage with the following statements:
HttpCookie cookie = FormsAuthentication.GetAuthCookie (UserName.Text,
RememberMe.Checked);
cookie.Expires = DateTime.Now + new TimeSpan (7, 0, 0, 0);
Response.Cookies.Add (cookie);
Response.Redirect (FormsAuthentication.GetRedirectUrl (UserName.Text,
RememberMe.Checked));
The first statement creates an authentication cookie; the second sets the cookie’s expiration
date to one week from the current date; the third adds the cookie to the Response object’s
Cookies collection, ensuring that the authentication cookie will be returned in the response;
and the fourth and final statement redirects to the page that the user requested before the
login form popped up.