Wednesday, March 31, 2010

.NET 4 ASP.NET ‘Video’s Overview’ 70-515 Exam Prep ASP.NET – Catto Code Crackin #15

Hey Now Everybody,

In this 15th post of the Catto Code Crackin series we’ll continue with the section ‘‘Video’s Overview’ Now that we’ve covered each section in detail I wanted to continue studying by taking a step back & review some highlights from ASP.NET 4 & VS10. Let’s look @ some of the top new features. WWW.ASP.NET is a great site for learning & flix are great to learn from. This is a summary of the videos from the offcial ASP.NET site.

Microsoft announced the .NET 4.0 Beta Exams on St. Patrick’s Day which are a free exam & if passed you get certified. Much of the study & prep materials are not available yet, therefore I’ve been studying for a similar exam 70-562 which is the .NET 3.5 ASP.NET Application Development. I hope by posting this content it will help myself along with other people in the community learn & get excited about .NET 4. If you are serious about studying for a MS Exam 2 must have resources: the Microsoft Self Paced training books are a great books to buy along with practice exams from eBay

This series of short videos introduces you to the new features of ASP.NET 4 & VS10

ASP.NET 4 Below are all the video’s & then a summary of them:

#1 | Chart Control
#2 | Dynamic Metadata
#3 | Permanent Redirect
#4 | Imperative WebForms Routing
#5 | Declarative WebForms Routing
#6 | Outbound WebForms Routing
#7 | Auto Start
#8 | Clean Web.Config Files
#9 | Predictable Client IDs
#10 | Selective View State
#11 | The HtmlEncoder Utility Method
#12 | New Rendering Option for Check Box Lists and Radio Button Lists

#13 | Persistent GridView Row Selection
#14 | Table Free Templated Controls
#15 | Easy State Compression
#16 | Tableless Menu Control
#17 | Imperative JavaScript Syntax for Microsoft Client Side Controls
#18 | The ScriptLoader
#19 | jQuery Syntax for Microsoft Ajax
#20 | AJAX Data Templates
#21 | Hidden Field Divs
#22 | Disabled Control Styling
Vs10
23 Code Optimized Profile
24 Code Search View Hierarchy
25 IntelliSense Smart Lists
26 Multi-Monitor Support
27 New Web Project Template
28 New Multi-Targeting
29 Websites Instead of Web Projects
30 Snippets IntelliSense
31 Use MSBuild to Automate the Compiler & 32 Merge Utilities

#1 | Chart Control
chart control in data catagorie form toolbox can use data source
Attributes Type such as bar, x & Y value member X such as title & Y # of sales
#2 | Dynamic Metadata – SEO uses MetaData
say the string contains the value we want
page.metadescription = “blah”;
page.metakeywords = “tomato ” & stringsstateId;
#3 | Permanent Redirect
Good since inbound traffic changes entry points for example a sub domain may change.
from the old page page_load event enter response.redirectpermanat(“~/newpage”);
http301
#4 | Imperative WebForms Routing – Imperative by code behind Allows clean URLs
old dirty release /Projectrelease.aspx?releaseid=33804
Good Clean downloads/realease/33804
using system.web.routing
add method
void registerTomatoRoutes(routecollection routes)
{
routes.mapPageRoute(
“list-show”
, “list/(type) “
, “list.aspx”
);
}
Void application_start(object sender, eventargs e )
( RegisterRoutes(routetables.routes);

The;n on asp.x page create link button w/ postbackURL=”~/list/people”>list / people <asp:linkbutton>

)
#5 | Declarative WebForms Routing – clean URLs global.aspx.cs enter route definition
#6 | Outbound WebForms Routing
#7 | Auto Start – specify windows/system / application host application pool always running needs to be set startmode=”AlwaysRunning” > then
2 set application to be prewarmed application host.config
‘we can pre warm cashe’ - there are a few steps for this one.
windows /system32 / inet serv config / choose app pool & set always running

C:\WINDOWS\system32\inetsrv
2 then in sites set two parms - service auto start enable = true
3 just below added serviceautostartproviders section

Then in application we created a class system.web

Specified a method preload & performed tasks on load
#8 | Clean Web.Config Files
only two enteries
#9 | Predictable Client IDs templated controls such as listview create datasource such as xml datasource then specify xpath ;
it’s a more straight forward programming model when we manipulate dom of server side controls
#10 | Selective View State – selectable view state options add placeholder control inside place label enableviewstate=”false” or enableviewstate=”true” for some controls
#11 | The HtmlEncoder Utility Method - put a button & label on page in button click event when untrusted stuff like script injection , or allow html to be displayed like if we wanted to display a code snippet on a page. This is why we’d use it. Run input threw a method to make sure it’s ran threw the utility method then it’s more secure
string untrustedInput = httputility.htmlEncode(“<script>altert(?);</script>”)
label1.text = untrusted string
#12 | New Rendering Option for Check Box Lists and Radio Button Lists
common theme in asp.net stills supports old version but us pretty ul not tables & spans
repeat layout property can be table, unordered list , or ordered list <ul> or <ol>

#13 | Persistent GridView Row Selection – after grid is wired up
when we select a row in the grid then switch page the row on the other enablepersistentSelect = “true” so if we select the fourth row then switch page the fourth row is not selected on page 2.
#14 | Table Free Templated Controls
some formview control w/ datasource uses tables by default <table> <tr> can be changed by renderoutertable = “false” this makes it not tables but removes the auto format style of the control
#15 | Easy State Compression – gets better performance on application. In web.config
<sessionState mode = “true”
add this one more - compressionenables = “true”>
#16 | Tableless Menu Control
Mneu property Rendering Mode change from table to List,
#17 | Imperative JavaScript Syntax for Microsoft Client Side Controls -
uses script loading need script files such as css sheet
lot’s of hoops to explain this topic
#18 | The ScriptLoader - great new feature use imperative syntax
sys.onread ? create an unordered list in javascrpt
#19 | jQuery Syntax for Microsoft Ajax interesting new feature drop scripts folder in project & add web form then add css folder. Used watermark control
#20 | AJAX Data Templates – used a web service
#21 | Hidden Field Divs - there is a div class on the hidden filed that we can style
DIV# aspentHidden
in css file :
{
Border: 0;
}

#22 | Disabled Control Styling – cool new feature for disabled fields. Ex Add textbox 2 buttons one button enables & the other disables the text box then the style of the textbox can differ suing the css below: new default css class any control that state is disabled
.aspnetDisabled
{
background-color: orange;
}

http://www.asp.net/learn/vs2010-quick-hit-videos/video-8774.aspx
23 Code Optimized Profile tools import & export settings web developer profile no toolbar icons & no tabs for design view tools options general chkbox for ‘enable design view’
24 Code Search View Hierarchy hightlight a word then press ctrl + , all the places will be displayed. If no word hightlighted hten ctrl + , we get intelligent search results kinda fuzzy search logic. Pascal case searching AMS (needs UPPER_case / caps) increase productivity for navigation
25 IntelliSense Smart Lists use of gridview code behind file gridview1. when intesllisence pops up there is contains search logic not just begins with search login for intellisense.
26 Multi-Monitor Support Nice just right click on the tab to rip it off!
27 New Web Project Template – The web project template is nice new to start kinda like the MVC one.
28 New Multi-Targeting – Of course we can target different versions of the framework.
29 Websites Instead of Web Projects – Opening websites is different in vs10 since there is no open web site
30 Snippets IntelliSense Improves our performance
31 use MSBuild to automate the ASP.NET Compiler & Merge Utilities

----------------------------------------------------------------------

Next up I’m really leaning to get into some more code & or review some of the training kit from Microsoft Downloads again. What do you think?

That is all, there will be more,

Catto

Tuesday, March 30, 2010

.NET 4 ASP.NET ‘Skills Overview’ 70-515 Exam Prep ASP.NET – Catto Code Crackin #14

Hey Now Everybody,

In this 14th post of the Catto Code Crackin series we’ll continue with the section ‘‘Skills Overview. Now that we’ve covered each section in detail I wanted to continue studying by taking a step back & look @ the skills measured in general. I looked at the MSDN library again for a while to obtain links along w/ links to my previous posts.

Microsoft announced the .NET 4.0 Beta Exams on St. Patrick’s Day which are a free exam & if passed you get certified. Much of the study & prep materials are not available yet, therefore I’ve been studying for a similar exam 70-562 which is the .NET 3.5 ASP.NET Application Development. I hope by posting this content it will help myself along with other people in the community learn & get excited about .NET 4. If you are serious about studying for a MS Exam 2 must have resources: the Microsoft Self Paced training books are a great books to buy along with practice exams from eBay

Skills Being Measured

This exam measures your ability to accomplish the technical tasks listed below.

clip_image002

1 Developing Web Forms Pages (19%)

* 1.1 Configure Web Forms pages.
* 1.2 Implement master pages & themes.
* 1.3 Implement globalization.
* 1.4 Handle page life cycle events.
* 1.5 Implement caching.
* 1.6 Manage state.

2 Developing and Using Web Forms Controls (18%)

* 2.1 Validate user input.
* 2.2 Create page layout.
* 2.3 Implement user controls.
* 2.4 Implement server controls.
* 2.5 Manipulate user interface controls from code-behind.

3 Implementing Client-Side Scripting and AJAX (16%)

* 3.1 Add dynamic features to a page by using JavaScript.
* 3.2 Alter a page dynamically by manipulating the DOM.
* 3.3 Handle JavaScript events.
* 3.4 mplement ASP.NET AJAX.
* 3.5 Implement AJAX by using jQuery.

4 Configuring and Extending a Web Application (15%)

* 4.1 Configure authentication & authorization.
* 4.2 Configure providers.
* 4.3 Create and configure HttpHandlers and HttpModules.
* 4.4 Configure initialization and error handling.
* 4.5 Reference and configure ASMX and WCF services.
* 4.6 Configure projects and solutions, and reference assemblies.
* 4.7 Debug a Web application.
* 4.8 Deploy a Web application.

5 Displaying and Manipulating Data (19%)

* 5.1 Implement data-bound controls.
* 5.2 Implement DataSource controls.
* 5.3 Query and manipulate data by using LINQ.
* 5.4 Create and consume a data service.
* 5.5 Create and configure a Dynamic Data project.

6 Developing a Web Application by Using ASP.NET MVC 2 (13%)

* 6.1 Create custom routes.
* 6.2 Create controllers & actions.
* 6.3 Structure an ASP.NET MVC application.
* 6.4 Create and customize views.

After viewing this it could be a good time to focus more on code for some of the next few posts. What do you think?

That is all there will be more,

CCatto

.NET 4 ASP.NET ‘Developing Web Forms Pages’ 70-515 Exam Prep ASP.NET – Catto Code Crackin #13

Hey Now Everybody,

.NET 4 ASP.NET ‘Developing Web Forms Pages’ 70-515 Exam Prep ASP.NET – Catto Code Crackin #13

Hey Now Everybody,

In this 13th post of the Catto Code Crackin series we’ll continue with the section ‘‘Developing Web Forms Pages’. This is the first section in the objectives but it’s the last one I chose to cover. In the .NET 3.5 Configuring and Deploying Web Applications (10 percent). In the .NET 4 exam the section is listed as ~19%.

Microsoft announced the .NET 4.0 Beta Exams on St. Patrick’s Day which are a free exam & if passed you get certified. Much of the study & prep materials are not available yet, therefore I’ve been studying for a similar exam 70-562 which is the .NET 3.5 ASP.NET Application Development. I hope by posting this content it will help myself along with other people in the community learn & get excited about .NET 4. If you are serious about studying for a MS Exam 2 must have resources: the Microsoft Self Paced training books are a great books to buy along with practice exams from eBay

.NET 4 - Key Objectives

Configure Web Forms

Implement Master pages & Themes

Globalization

Page Life Cycle

Cashing

Managing State

Here are the official skills measured for the 70-515:

Developing Web Forms Pages (19%)

Let’s continue with some key points on these topics from the 3.5 book:

Master Pages:

Master pages provide templates that you can use to create consistent web pages though out an app.

To use master pages, create a master page & add site layout info & other common elements. Add 1 or more multiple ContentPlaceholder controls to the master page.

To create the content pages, add standard web forms to our site and select the Select Master Page check box when creating the page. Then add content inside the content placeholder control.

To reference public properties in a master page, add the @ MasterType declaration to the content page & reference the property using the Master<propertyname> to reference controls in a master page call the Master.FindControl from the content page.

Nested Master pages fit into the ContentPlaceHolder controls on a master page but can contain other content pages. To create a nested master page, add a master attribute to the @ Master page declaration & specify the parent master page.

To programmatically change the master page for a content page, set the page’s MasterPageFile property & reload the page.

Web parts

Web parts are controls that you create using custom controls that implement the web part class or stand user controls & ASP.ENT contrls. Web Parts are aslo managed b ASP.NET which allows users to close , minimize, move & edit them.

To enable users to edit or rearrange eb parts, you change the displaymode property of the webPartManager contrl on our page

Web Parts can be connected to enable them to share data. We do so by defining both consumer & provider web parts using the attribute-based programming medel Also we configure the connections between web parts by adding a <staticConnections> element in the WebPartManager contorl

To add web parts to a page add a WebPartManager control to the top of the page add WebPartZone containers to the page & then add controls to the WEbPartZone Containers.

Themes 5.2

To create a theme add an App+Themes subfolder to our app. Then for each theme in your site add a folder. The folders name becomes the name of your theme. Blog Engine .NET is a good example of this.

Themes contain skin files, a style sheet, images & other resouces.

We can apply a theme at the page level or site level thought the web.config at the individual control level.

Intrinsic Objects:

You can use the Request object to examine detail of the client web browser’s request to the web server, including the request headers, cookies client certificate, query string & more. You can use the Response objecdt to send data directly to the client w/out using standard ASP.NET server controls. You can use Server object’s static methods to perform of HTML & URL data. The context object provides several unique methods for adding errors & enabling debugging.

You can use the Browser object to determine the client Web Browser type & whether it supports cookies, ActiveX, JS, & other capabilities that can affect its ability to render your web pages correctly.

Use the Page Header.StyleSheet object to dynamically set the page style sheet including info such as the bg color & use the Page.HeaderTitle object to dynamically set the page title

Business Objects & Utility classes

ASP.NET 3.5 supports the file system web site type. This is good option when IIS is not installed on the dev’s pc & the developer wants to create a Web site w/out the use of remote web server.

ASP.NET 3.5 supports the FTP web site types. This option can be used when building a web site that is being hosted on a remote pc that does not have front page server extensions installed.

ASP.NET 3.5 supports the HTTP web site type. This option is a good choice when IIS is installed on a dev’s pc or on a remote server w/ Front Page Server extensions installed.

FTP in ASP.NET 3.5 active mode is the default. However, passive mode can solve communication problems when the client has to go through a firewall.

ASP.NET supports 2 programming models for pages. Single file & code behind . With the single file programming model all of the web page markup & code are in a single file. With the code behind model, the server side code is separate from the markup & put into a separate file such as.cs or .vb.

In ASP.NET 3.5 dynamic complication refers to the delayed complication of pages that taks place when a user requests a page.

ASP.NET 3.5 defines several folders. When a new site is created, the App_data folder is created by default. It can contain a SQL Server database, XML data file that will be used in the site.

A browser is used to make requests to a server. It renders HTML to the user, collects data from the user, & sends data back to the server. The server is responsible for accepting a resource request & sending the appropriate response. The communication between browser & server is done via the text-based communication protocol HTTP.

ASP.NET 4 supports 3 web site types: file system, FTP & HTTP

ASP.NET 4 supports two programming models for pages: single file & code behind

Visual Studio allows us to select a programming language for each web page.

ASP.NET 4 uses a hierarchy of config files that can be modified to manage the settings of an app.

ASP.NET pages have a defined cycle that determines how ASP.NET will process the page, call events, & collect data to the page.

ViewState is the mechanism by which web page object & child control object data can be maintained between page request.

A server control is a control that is programmable by writing server-side code to respond to events from the control.

Server controls contain runat=”server”

State Management

Use client side management when scalability is the top priority Use of server side state management when data must be better protected or when bandwidth is a significant issue.

ASP.NET uses view state by default to store info about controls in a web form. We can add custom values to view state by accessing the ViewState collection.

Use control state when a custom control cannot function with view state disabled.

Use hidden fields to store data in forms when view state is disabled. Hidden fields values are available to users as plaintext in the HTML.

Cookies store data on the client that the web browser submits with every web page request. Use cookies to track users track users across multiple pages.

Query Strings store small pieces of info in a hyperlink’s URL. The query strings when you want state management data to be bookmarked such as displaying multiple pages of search results.

Web site programmability

You can catch unhandled exceptions at the page level by responding to Page_Error or at the app level by responding to Application_Error. In either event handler, you read the last error by calling Server.GetLastError. Then you must remove it from the queue by calling Server.ClearError.

You can call WEbConfigurationManager.GetSection to return a configuration section from the web.config file. You cast the returned object to the section specific type. If you make an update to the conf strings write the changes by calling configuration.Save or Configuration.SaveAs

Config App Pools & Compile Application;
Deploying, Configuring & Cashing Applications

Web setup Project allow us to create executable setup.exe files & windows installer packages (.msi ) that admins can use to easily deploy our apps to a server

The copy web tool can synchronize a web site between a server & our local pc. This is useful if we want to do deployment testing on our local pc and then upload the website to a server. The copy web tool can also be useful in environments with multiple developers since it detects versioning conflicts.

Precompiling a web app removes the delay that occurs when a ASP.NET compiles an application after the first user request. Use the web site publish tool to precompile a web app. The web site publish too l in located in the build menu. We then select the destination such as FTP or local IIS. There are a couple of options worth noting for this such as the ‘Allow this precompiled site to be updated, ‘use fixed named & single page assemblies’ & ‘enable strong naming on precompiled assemblies’

’We can use the Cashe object to store data of any types. You can then access the cached data from other web pages in our app. The cashe object is an excellent way to reduce the # of db’s calls & file reads. Use the Cashe Add & Cashe.Insert methods to add an object to the cashe with dependency to ensure the cashed object does not become stale.

Page output cashing stores a copy of rendered page in the servers memory. Subsequent requests for a given resources are served from memory page Output caching practically eliminates rendering time.

User Profiles, Authorization, Authentication

We can configure user profiles using the web.config file & the <profile> element. We add fields to this element based on which data elements we intend to track users on our site.

ASP.NET automatically creates strongly typed objects based on our profile filed settings in the web.config file. We can access this calss & it’s properties through the Profile <fieldname> syntax in our code.

We call the profile.Save method to save users profile to the db

By default, ASP.NET uses the SQLProfileProvider to store & retrieve user profile information to a SQL Server db called aspnetdb.mdf . We can change the db to connect to a SQL Server db by eding the connection strings.

Exam Questions Concepts:

1 - Unless you specifically narrow the scope, the user's browser submits information stored in a cookie to every page on your site. Therefore, each page processes the user preference information. If you configure the cookie expiration to make it persistent, the browser submits the cookie the next time the user visits your site.

2 - Storing user name & password. Server-side state management provides better security for confidential information by reducing the number of times the information is transmitted across the network.

3 When you have a web part and want another web part to connect to it you should apply the ConnectionProvider attribute to a public method to allow consumers to access the method.

4 The Application object allows you to store data that is scoped at the application level and therefore available to all users.

5 Guidelines that ASP.NET provides automated testing for the following:

Visual Studio can automatically test Web applications for compliance with WCAG Priority 1 guidelines.

Visual Studio can automatically test Web applications for compliance with WCAG Priority 2 guidelines.

Visual Studio automatically tests Web applications for compliance with Section 508 guidelines.

5 Catch unhandled exceptions in an app by:

catch errors at the page level by trapping the Page_Error method.

catch application-wide, unhandled errors by trapping the Application_Error method inside the Global.asax file.

6 View state is the simplest way to store this information. Because it is enabled by default, you might not need to write any code to support state management for your form.

7 Log data to a db when a users session logged out. Respond to the Session_End event. The Session_End event handler is called when a user's session times out. However, this event will not fire in the event of the server being shut off unexpectedly or if the SessionState mode is not set to InProc.

8 Visual Studio provides an editor for the (Expressions) property that enables you to link any other property to a global resource.

9 A master page cannot be a web part but a control could be

10 The IsPostBack property indicates if the client is sending data as part of its request (true) or the page is simply being requested for display (false).

11 You can use the Cache.Insert method to add an object to the cache and specify one or more dependencies, including an expiration time span.

12 Dynamically change master page use the page_PreInit event. Page_PreInit is the last opportunity to change the master page. After this event, the page binds with the master page, preventing you from changing it.

13 The @ MasterType declaration is required to access the properties in the master page.

Content pages must have a MasterPageFile attribute in the @ Page declaration that points to the master page.

14 Themes can be specified in the Page_PreInit event

15. Store a value indicating whether a user is authenticated or not can be stored in session. This prevents the user from hackin with the data.

16 ASP.NET uses the Image.AlternateText parameter to create the alt text for an image. Screen readers typically describe images using the alt text.

DescriptionUrl links to an HTML page that provides a long description of an image. ASP.NET uses this link to create the longdesc HTML attribute.

17 The Flush method sends the current output to the client without ending the response.

18 Server.GetLastError retrieves the most recent error message. After processing it, you call Server.ClearError to remove the error from the queue.

19 The Global.asax file allows you to trap special events such as the Application_Start event.

20 Query strings are stored in the URL. Although they are not the easiest type of client-side state management to implement, they are the only way to enable state management data to be easily bookmarked and e-mailed.

21 The SiteMap class will allow you to load the given site map file and work with the data contained inside.

22 You can make a Cache object expire after a specific time span or at a specific time.

23 PreInit event is where we can store our dynamically generated controls.

24 The SiteMapPath will automatically pick up a site map file and display its contents to a user.

25 Skin files <asp:Label runat="server" BackColor="#FFE0C0" ForeColor="Red"></asp:Label> have not ID attribute

26 Track non confidential info - Client-side state management is an excellent choice for storing nonconfidential information. It is much easier to implement than server-side state management when multiple Web servers are involved, and it minimizes load on the servers.

27 The Page.Server.Transfer method transfers the page processing to another page without calling back to the client.

28 Creating & writing file on serve is indicated by the HTTP verb – PUT..

29 Themes will override attributes directly on a control:
A theme specified using @ Page Theme="MyTomatoTheme"
<pages Theme="themeNameTomato"> element in the Web.config file

30. Retrieve current cookie config settings
HttpCookiesSection section = (HttpCookiesSection)
WebConfigurationManager.GetSection("system.web/httpCookies");

31 The Response object contains methods such as Response.Cache.SetExpires and Response.AddCacheDependency that enable you to configure page output caching programmatically.

32 Configuring IIS to use worker process isolation mode allows you to create application pools.
33 The Publish dialog box allows you to precompile a Web site. It also allows you to publish from your development server.

34 Windows Authentication: The only step you need to take to enable the user's credentials to be passed to the database server is to enable impersonation

35 To configure the app pool to shut down & restart on a specific time we can add the time to the Recycle Worker Processes At The Following Times list on the Recycling tab of the application pool Properties dialog box to ensure that the process is recycled at a specific time.

36 With an ASP.NET Web Application project you can use the Publish Web dialog box to publish a Web application.

37 We want to rely on ASP.NET dynamic compilation for iterative modifications Create an ASP.NET Web site if you want to rely on ASP.NET dynamic compilation for iterative modifications. The Build command compiles Web site projects only to test them. To run Web sites, you can deploy source files and rely on ASP.NET dynamic compilation to compile pages and classes in the application.

38 Publish Dialog Box: Clear the Allow This Precompiled Site To Be Updatable check box to ensure that pages cannot be updated on the Web server.
39 The ASP.NET Merge tool (Aspnet_merge.exe) enables us to combine and manage assemblies that are created by the ASP.NET Compilation tool (Aspnet_compiler.exe). The ASP.NET Merge tool provides additional flexibility when you precompile the Web site beyond what you can achieve with the ASP.NET Compilation tool alone.

40 We need to configure session state to allow state to be shared across servers. StateServer mode stores session state in a separate process called the ASP.NET State Service. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.

SQLServer mode stores session state in a SQL Server database. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.

41 Session state stores state management information on the server and tracks a user with a single cookie. Session state is ideal for scenarios such as this because it tracks a user's information for a single visit across multiple Web pages.

42 Given integrated Windows IIS authentication, Windows ASP.NET authentication, and ASP.NET impersonation, ASP.NET will assume the client identity. You must add the accounts of the users requesting the Web page to the database.

43 We must define a membership provider to indicate the membership information store. Designate a membership provider by setting the defaultProvider attribute of the membership element to AspNetSqlProvider.

44 When users access the web app by a browser with cookies disabled. The state mode should be configured as cookieless and using InProc mode.

45 We can easily determine whether a user is in a specific role by calling Roles.IsUserInRole. Alternatively, you can call Roles.GetRolesForUser and iterate through each role to determine user membership.

46 If ASP.NET Windows authentication is configured, we must configure IIS Basic, Digest, or Integrated Windows authentication., We cannot use Integrated Windows authentication if users must authenticate through a firewall.

47 The assembly must be manually copied to the local Bin folder. Referencing from the GAC and configuring Copy Local no longer works in Visual Studio 2008.

48 If we are using a database (SQL Server ), we must run Aspnet_regsql.exe, which is found in %windows%\Microsoft .NET\Framework\<version>. When you run the tool, we specify the -Ap option.

49 With an ASP.NET Web Application project we have complete control of the project's structure, namespaces, and compilation.

50 Digest authentication, as well as Integrated Windows authentication or Basic authentication, support only Windows authentication.

51 Windows authentication can automatically authenticate users to either the Active Directory domain or the local user database. The user's browser can submit the credentials he or she used to log in to his or her computer without prompting the user for a user name and password.

52 The ASP.NET Compilation tool (Aspnet_compiler.exe) enables us to compile an ASP.NET Web application, either in place or for deployment to a target location such as a production server. In-place compilation helps application performance because end users do not encounter a delay on the first request to the application while the application is compiled. We can provide Aspnet_compiler options to prevent the copy of .aspx files.

----------------------------------------------------

Let’s continue with some Code

State Management code:

ASPX

<div>
Default Page 2 <br />
<asp:Label ID="LabelApplicationClicks" runat="server" Text="Label"></asp:Label>
<br />
<asp:Label ID="LabelSessionClicks" runat="server" Text="Label"></asp:Label>
<br />
<asp:HyperLink ID="HyperLinkPage1" runat="server" NavigateUrl="~/Default.aspx">HyperLink</asp:HyperLink>
</div>

.cs

public partial class Default2 : System.Web.UI.Page

{
protected void Page_Load(object sender, EventArgs e)
{
Application.Lock();
Application["clicks"] = ((int)Application["clicks"]) + 1;
Application.UnLock();
LabelApplicationClicks.Text = "Application clicks: " +
Application["clicks"].ToString();
Session["session_clicks"] =
(int)Session["session_clicks"] + 1;
LabelSessionClicks.Text = "Session clicks: "
+ Session["session_clicks"].ToString();
}

Xml file web.config for users & roles:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<authorization>
<allow roles="Administrators" />
<deny users="*" />
</authorization>
</system.web>
</configuration>

So we’ve reviewed the Programming Web Applications section & seen some important topics such as appearance, state, layout along with others.

Wow in the 13 posts we covered quite a bit. I think maybe the next posts can be just a random material or more code focused or a summary. We’ll soon find out. Hope your enjoying studying & learning the content like me. What do you think?

That is all there will be more,

Catto

Monday, March 29, 2010

.NET 4 ASP.NET (da Gu’s & whitepaper) 70-515 Exam Prep Catto Code Crackin #12

Hey Now,

In this 12th post of the Catto Code Crackin series we’ll continue with the section ‘da Gu & WhitePaper’. In .NET 4 there are many new features. I wanted to take a break from the book so I figured let’s check out what da Gu posted on the new .NET 4 features & the official whitepaper.

Microsoft announced the .NET 4.0 Beta Exams on St. Patrick’s Day which are a free exam & if passed you get certified. Much of the study & prep materials are not available yet, therefore I’ve been studying for a similar exam 70-562 which is the .NET 3.5 ASP.NET Application Development. I hope by posting this content it will help myself along with other people in the community learn & get excited about .NET 4. If you are serious about studying for a MS Exam 2 must have resources: the Self Paced training books are a great books to buy along with practice exams from eBay.

Da Gu’s Blog post

1. Multiple Monitor Support
2. Built-in Charting Controls for ASP.NET and Windows Forms
3. URL Routing with ASP.NET 4 Web Forms
4. SEO Improvements with ASP.NET 4
5. Searching and Navigating Code in VS 2010
6. Auto-Start ASP.NET Applications
7. Clean Web.Config Files
8. VS 2010 Code Intellisense Improvements
9. New Code Focused Web Profile Option
10. Starter Project Templates
11. Multi-targeting
12. HTML / ASP.NET / JavaScript Code Snippets .
13. Add Reference Dialog Improvements
14. Output Cache Extensibility with ASP.NET 4
15. WPF 4

Details

  1. Multiple Monitor Support
    • We can rip a tab of in the VS IDE & move it anywhere such as another monitor. Kind like how Chrome treats tabs.
    • We can do this by clicking on a code file tab, then drag it outside the VS IDE
  2. Built-in Charting Controls for ASP.NET and Windows Forms
    • Wow this topic is huge 4 guys from Rolla placed some great content
    • <asp:chart> control: it’s in data section of tool box
    • Chart Picture
    • Series
    • Chart Area
    • Sorting & many more
  3. URL Routing with ASP.NET 4 Web Forms
    • URL Routing is good for SEO
    • SEO friendly URLs
    • No more query strings within URLs
    • Allows Mapping URLs
  4. SEO Improvements with ASP.NET 4
    • SEO is good since we can add meta tags & there are more page properties
    • New Page MetaKeywords & Page.MetaDescriptions properties
    • URL Routing
    • Response.RedirectPermanent() method (when we move content)
  5. Searching and Navigating Code in VS 2010
    • Searching in VS2010 has seen improvements
    • Navigate To –
    • (Ctrl+comma) keyboard shortcut open Navigate To dialog box
    • Fuzzy Search allows smart filters (when we don’t know exactly the name)
    • View Call Hierarchy allows us to discover where a method or property is being called from.
    • Ctrl + K, Ctrl + T Open View Call Hierarchy menu command.
    • Highlighted References can be cycled threw by Ctrl+Shift+Up Arrow.
  6. Auto-Start ASP.NET Applications
    • There is an oiption for Auto start
    • Our apps can be warmed up with ASP.NET 4 & IIS 7.5 by performing application startup & pre=cache logic run before any user hit the app.

§ <applicationPools>

§ <add name="MyAppWorkerProcess" managedRuntimeVersion="v4.0" startMode="AlwaysRunning" />

§ </applicationPools>

  1. 7 Clean Web.Config Files
    • Clean Web Config Files are stripped down into a simple web.config file
    • Here it is:
§  <?xml version="1.0"?>
§ <configuration>
§ <system.web>
§ <compilation targetFramework="4.0" />
§ </system.web>
§ </configuration>
  1. 8 VS 2010 Code Intellisense Improvements

    • Pascal Case Intellisense when we type GridView1.PIC then the intellisense will display the PageIndexChanged member.
    • Searching for Types is new for example type list & we’ll see list<>, SortedList<> ect.
    • Intellisense filtering – Insellisense w/ fuzzy logic kinda.

  2. 9 New Code Focused Web Profile Option

    • New environment settings: Web Development (code optimized ) – Anti WYSIWYG
    • This affects how tool windows are displayed / hotkeys
  3. 10 Starter Project Templates

    • Start Projects New Templates are nice such as
    • Empty ASP.NET Web Application – minimal project
    • ASP.NET Web Application (has master pages, layout / CSS / directories such as styles & scripts)

  4. 11 Multi-targeting

    • We can target .NET 4 or .NET 3.5 or .NET 2.0 diifferent framework versions
    • This feature is more accurate & better than in VS08
    • Reference Assemblies for each .NET versions is in VS10
    • Internal IIS ASP.NET dev server lists the .NET version now previously it listed the root url, port, virtual path, physical path & stop button.

  5. 12 HTML / ASP.NET / JavaScript Code Snippets

    • There are many code snippets available to us
    • Example is when we can start typing a control then get intellisence, then press tab to complete the control name then press tab a second time to complete the control code.

  6. 13 Add Reference Dialog Improvements

    • Adding Reference Dialog box is much improved. Speedier
    • Quicker including a Project tab
  7. 14 Output Cache Extensibility with ASP.NET 4

    • Cache Extensibility is good
    • The addition of the output cache provider enables us devs to easily pursue more aggressive & more intelligent output caching strategies for sites & apps.
    • Improve performance & responsiveness

  8. 15 WPF 4

    • WPF 4 is dead right w/ Silverlight 3 out of browser?
    • Controls are improved in WPF4
    • Office Ribbon
    • Graphics & many more

Here are a couple other topics from the white paper

Here are the main points from the white pager:

Core Services

New Features in AJAX Library


Web Forms
ASP.NET MVC
Dynamic Data
VS 2010 Improvements
Web Application Deployment w/ VS10

& here are some topics that catch my eye & I feel are important for the exam:

Query Extender control – used to modify the results from a query from a data source control
CSS improvements – less table layouts. Examle the menu control now uses un ordered lists not tables wihich makes it render better in webkit.
Chart Control is a really good control for us to us. It has 36 distinct charts, chart areas, titles, can use AJAX with it, smart data labels, filtering & much more.
Wizard Controls & CreateUserWizard controls <asp:CreateUserWizard Dynamic Data – Big sections here including enabling dynamic data for existing sites, creating new projects of dynamic data types, support for filters & more.

As we’ve seen .NET 4 has quite a few enhancements, Scott Gu’s blog & the whitepaper are great resources for us.

That is all, there will be more,

Catto

Saturday, March 27, 2010

.NET 4 ASP.NET Congifuring & Deploying Web Applications 70-515 Exam Prep ASP.NET – Catto Code Crackin #6

Hey Now Everybody,

In this 6th post of the Catto Code Crackin series we’ll continue with the section ‘Working with Data & Services’. In the .NET 3.5 exam ‘Config & Deploying Web Apss’ are ~10%. In the .NET 4 exam the section is listed as ‘Config & Deploying Web Apps is listed as 19%. Data to me is very fun to work with. It’s one topic that where I’m very interested in learning new data access layers & spending time developing with data driven sites.

Microsoft announced the .NET 4.0 Beta Exams on St. Patrick’s Day which are a free exam & if passed you get certified. Much of the study & prep materials are not available yet, therefore I’ve been studying for a similar exam 70-562 which is the .NET 3.5 ASP.NET Application Development. I hope by posting this content it will help myself along with other people in the community learn & get excited about .NET 4. If you are serious about studying for a MS Exam 2 must have resources: the Self Paced training books are a great books to buy along with practice exams from eBay.

Let’s start with taking a look at the official skills measured from MS. Here are the main points from the skill:

1 Authorization
2 Config Providers
3 HttpHandlers
4 Init & Error Handling
5 Ref & Config Services
6 Projects & Solutions
7 Debugging
8 Deploying

Configuring and Extending a Web Application (15%)

Now book important content from chapter 14, 16 & another 4?

Ch 1.3 Working with Web.Config Files

Web sites based on a hierarchy of XML configuration files, starting with the machine.config. followed by the web.config file that is in the same folder. After that you might have a web.config file in the root of the website in each web app & in any subdirectory in a web app.

The config file can be edited with a text XML editor (I always 99.9% of time use Visual Studio). The configuration snap in for MMC or the WSAT

The WSAT is used to add and modify the web site settings.

Ch 4.2 You can use the Application collection to store info that is accessible from all web pages but is not user specific. To initialize Application variables respond to the Application_Start event in your global.aspx file.

You can use Session collection to store user specific information that is accessible from all web pages To initialize Session variables respond to the session_start event in your global.aspx file You can store session info in the servers memory using the inProc session state mode store it in ASP.NET State Service server using the StateServer mode store in a database using the SQL Server mode implement your own custom session state storage using the custom.mode or turn session state off completely.

Ch 16.1. Web setup projects allow you to create executable setup.exe files and windows installer packages (.msi files ) that administers can use to easily deploy your app to the web servers

The copy web tool can synchronize a web site between a remote and your local pc. It’s good cause if we want to deploy & test on your local pc & then upload the site to a remote web servers. The copy web tool can also be useful in environments with multiple developers because it detects versioning conflicts.

Pre compiling a web app removes the delay that occurs when ASP.NET compiles an application after the first user request. To precompile a web app use the Publish web site tool.

You can use the Cache object to store data of any type. You can then access the cashed data from other web pages in your app. The Cache object is an excellent way to reduce the number of database calls & file reads. Use the Cache.Add and Cache.Insert methods to add an object to the cache with a dependency to ensure the cached object does not become stale.

Page output caching stores a copy of a rendered page (or user control) in the server’s memory. Subsequent requests for the given resources are served from memory. Page output caching practically eliments rendering time.

Configure authentication, authorization & impersonation

14.1 Working with Profiles

14.2 Using ASP.NET Membership

14.3 Securing Your Site

You can configure user profiles using the Web.config file & the <profile> element. You add fields to this element based on which data elements you intend to track for users of your site.

ASP.NET automatically creates a strongly types object based on your profile field setting in the web.config file. You can access this class & it’s properties through the Profile <FiledName> syntax in your code.

You call the Profile.Save method to save a user’s profile to a database.

By default ASP.NET uses the SQLProfileProvider to store & retrieve user profile information to a SQL Server DB canlled ASPNETDB.mdf. You can change the provider & db using configuration files friendly adjustments.

ASP.NET provides several login controls to enable you to easily build pages that support creating user accounts, logging in, logging out, & resetting passwords. These controls include loginView, LoginStatus< PasswordRecovery, CreateUserWizard, & ChangePassword. (this is a good one eh?)

Use the Membership class when you need to perform user management tasks from w/in your code, such as creating, deleting, or modifying user accounts. This class enables you to create custom forms that provide similar functionalitly to that provided by the standasrd ASP.NET login controls.

Use the Roles class when you need ot perform role management tasks from within you code such as adding users to roles, removing users from roles, creating new roles, or examining to which roles a user belongs.

You can fonfigure an app to require Windows credentials from a user by either configuring IIS, configureing the web.config file or both.

To create custom ASP.NET forms for user authentication, first configure your Web.Config file to specify the authentication form. Then creat an ASP.NET web form to prompt the user for credentials & write code to verify the credentials & the authenticate the user. You should also provide a way for users to log off.

ASP.NET web apps support Passport which uses a centralized authentication service provided by Microsoft for a fee. (not included in the .NET 4 exam. Cardspace of .NET 3 hasn’t yet taken off eh?)

If an app does not require authentication, you can explicitly configure it for anonymous access.

By default, ASP.NET accesses resources using ASP.NET credentials. If you need to access resources from the user’s account or from a specific user account. You can use impersonation, ieither from withing your code or by configuring the web.config file.

To control which users can access folders & files in a web app, you can use either NTFS file permissions or web.config files.

Sites identify users. Authentication verifies a user.

----------------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------

Exam questions study style

1 Create a user profile that uses a custom type as one of the profile properties.

Custom types that you wish to use as profile properties must be marked serializable.

When you use a custom type, you must qualify it by namespace and class in the type attribute of the profile property.

2 The Publish Web Site tool is used to precompile and deploy Web sites. Precompiling reduces the delay when the first user requests a Web page, improving initial responsiveness of a site.

3 The code-behind model is used to separate code and user interface markup. Far from the MVC architecture.

4The LoginStatus control displays "Login," with a link to log in if the user is unauthenticated, or "Logout" to authenticated users.

5 The Copy Web tool detects when a version of a file has been modified on the Web server after it is synchronized with the local copy of a file. Therefore, it can detect versioning conflicts when multiple developers work on a single site.

6 In 3.5 we can combine both C# and VB pages in a single Web site.

7 Which of the following Web.config files correctly enables the Web application to track the age of anonymous users in a variable of type Int32?

<anonymousIdentification enabled="true" />
<profile>
<properties>
<add name="Age" type="System.Int32" allowAnonymous="true" />|
</properties>
</profile>

8 A Web form that enables users to log in to your Web site. 2 controls we could use is:

The Login control is required on a login page, because it prompts the user for a user name and password.

The PasswordRecovery control is a good choice for a login page because it can be used to recover a password in the event the user forgets his or her password.

9 Our application is being deployed in a load-balanced Web farm. The load balancer is not set up for user server affinity. Rather, it routes requests to servers based on their load. Your application uses session state. We should configure the SessionState mode attribute as follows:

You must manage session state on a central server in this case. StateServer allows you to do so.

You must manage session state on a central server in this case. SqlServer allows you to do so.

10 WSAT tool will allow you to manage the settings for a single Web application. In addition, you can do so through its Web-based interface.

11 Remote HTTP can be used for remote servers with Front Page Server Extensions installed and enabled.

12 Web.config requires that all users be authenticated using a Windows user account:

<authentication mode="Windows" />
<authorization>
<deny users="?" />
</authorization>

13 Any installation changes you make should occur in the Install phase.

14 After a user creates an account, he or she is notified of the successful account creation and prompted to click Continue. The ContinueButtonClick event is called when the user clicks that button.

16 Web.config file at the Web application root will apply only to that Web application.

18 You can use the Machine.config file to manage settings for both Web and Windows applications at the machine level.

19 <configuration>
<system.web>
<authentication mode="Windows" />
<authorization>
<deny users="?" />
</authorization>
</system.web>

<location path="Marketing">
<system.web>
<authorization>
<allow roles="Catto\Marketing" />
<deny users="*" />
</authorization>
</system.web>
</location>
</configuration>

Members of the Catto\Marketing group have access. All other users are denied access.

21 When no filename is specified in the Web.config file, ASP.NET redirects unauthenticated users to the Login.aspx page, regardless of whether the page exists.

22 Rollback phase is used to remove changes made during the Install phase if setup is cancelled or otherwise fails. Therefore, you should undo your registry modification here if the change has already taken place.

More Section 1 Exam Practice

1.1 ASP.NET Web App project you can use the Publish Web dialog box to publish a Web application

1 2 StateServer mode stores session state in a separate process called the ASP.NET State Service. This ensures that session state is preserved if the Web application is restarted & also makes session state available to multiple Web servers in a Web farm.

SQLServer mode stores session state in a SQL Server database. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.

1 4 The Publish dialog box allows you to precompile a Web site. It also allows you to publish from your development server.

1 5 Session state stores state management information on the server and tracks a user with a single cookie. Session state is ideal for scenarios such as this because it tracks a user's information for a single visit across multiple Web pages.

1 6 Windows authentication can automatically authenticate users to either the Active Directory domain or the local user database. The user's browser can submit the credentials he or she used to log in to his or her computer without prompting the user for a user name and password. It’s not forms auth.

1 9 With an ASP.NET Web Application project you have complete control of the project's structure, namespaces, and compilation.

1 10 Create an ASP.NET Web site if you want to rely on ASP.NET dynamic compilation for iterative modifications. The Build command compiles Web site projects only to test them. To run Web sites, you can deploy source files and rely on ASP.NET dynamic compilation to compile pages and classes in the application.

1 11 Digest authentication, as well as Integrated Windows authentication or Basic authentication, support only Windows authentication.

1 12 ASP.NET Compilation tool (Aspnet_compiler.exe) enables you to compile an ASP.NET Web application, either in place or for deployment to a target location such as a production server. In-place compilation helps application performance because end users do not encounter a delay on the first request to the application while the application is compiled. We can provide Aspnet_compiler options to prevent the copy of .aspx files.

1 13 The assembly must be manually copied to the local Bin folder. Referencing from the GAC and configuring Copy Local no longer works in Visual Studio 2008.

1 15 You must define a membership provider to indicate the membership information store. Designate a membership provider by setting the defaultProvider attribute of the membership element to AspNetSqlProvider.

1 17 The ASP.NET Merge tool (Aspnet_merge.exe) enables you to combine and manage assemblies that are created by the ASP.NET Compilation tool (Aspnet_compiler.exe). The ASP.NET Merge tool provides additional flexibility when you precompile the Web site beyond what you can achieve with the ASP.NET Compilation tool alone.

1 18 Given integrated Windows IIS authentication, Windows ASP.NET authentication, and ASP.NET impersonation, ASP.NET will assume the client identity. You must add the accounts of the users requesting the Web page to the database.

1 19 You can easily determine whether a user is in a specific role by calling Roles.IsUserInRole. Alternatively, you can call Roles.GetRolesForUser and iterate through each role to determine user membership.

Roles.GetAllRoles retrieves a list of all roles that exist, regardless of role memberships.

1 20 Aspnet_regsql.exe, which is found in %windows%\Microsoft .NET\Framework\<version>. There is an -Ap option.

Show some Code:

Good old login control

<form id="form1" runat="server">
<div>
<asp:Login ID="Login1" runat="server">
</asp:Login>
</div>

In webconfig

<authorization>
<deny users="?" />
</authorization>

. Master page with user profile

Masterpage.master.cs

public partial class MasterPage : System.Web.UI.MasterPage
{

protected void Page_Load(object sender, EventArgs e)
{
if (Profile.Name.Length > 0)
{
HyperLinkUserProfile.Text = "Welcome, " + Profile.Name;
}
else
{
HyperLinkUserProfile.Text = "Set Profile";
}
if (Profile.ColorPreference.Length > 0)
{
Panel1.BackColor =
System.Drawing.Color.FromName(Profile.ColorPreference);
}
}

Masterpage.master

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>My Site</title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body style="font-family: Verdana">
<form id="form1" runat="server">
<asp:Panel ID="Panel1" runat="server">
<h1>My Site</h1>
<hr />
<div style="float: right">
<asp:HyperLink ID="HyperLinkUserProfile" runat="server"
NavigateUrl="UserProfile.aspx"></asp:HyperLink>
</div>
<asp:ContentPlaceHolder id="ContentPlaceHolderMain" runat="server">
</asp:ContentPlaceHolder>
</asp:Panel>
Userprofile.cs

public partial class UserProfile : System.Web.UI.Page

{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
TextBoxName.Text = Profile.Name;
if (Profile.PostalCode > 0)
{
TextBoxPostal.Text = Profile.PostalCode.ToString();
}

if (Profile.ColorPreference.Length > 0)
{
DropDownListColors.SelectedValue = Profile.ColorPreference.ToString();
}
}
}

protected void ButtonSave_Click(object sender, EventArgs e)

{
Profile.Name = TextBoxName.Text;
Profile.PostalCode = short.Parse(TextBoxPostal.Text);
Profile.ColorPreference = DropDownListColors.SelectedValue.ToString();
Profile.Save();

Response.Redirect("Default.aspx");
}
}

As we see we covered the ‘Configuring & Deploying Web Applications’ section What are your thoughts on this section?

That is all & there will be more,

Catto