Web Developer Framework 4.0 Sample Questions – 8

Question: You are creating an ASP.NET Web site. The site is configured to use Membership and Role management providers. You need to check whether the currently logged-on user is a member of a role named Administrators. Which code segment should you use?

  1. bool isMember = Roles.GetUsersInRole(“Administrators”).Any();
  2. bool isMember = Membership.ValidateUser(User.Identity.Name, “Administrators”);
  3. bool isMember = Roles.GetRolesForUser(“Administrators”).Any();
  4. bool isMember = User.IsInRole(“Administrators”);

Correct Answer: 4


Question: You are implementing an ASP.NET Web application. Users will authenticate to the application with an ID. The application will allow new users to register for an account. The application will generate an ID for the user based on the user s full name. You need to implement this registration functionality. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

  1. Configure the SqlMembershipProvider in the web.config file.
  2. Configure the SqlProfileProvider in the web.config file.
  3. Create an ASP.NET page that contains a default CreateUserWizard control to create a new user account.
  4. Create an ASP.NET page that contains a custom form that collects the user information and then uses the Membership.CreateUser method to create a new user account.

Correct Answer: 1 & 4


Question: You are creating an ASP.NET Web site. You create a HTTP module named CustomModule, and you register the module in the web.config file. The CustomModule class contains the following code. public class CustomModule : IHttpModule {string footerContent = “<div>Footer Content</div>”; public void Dispose( ) {} } You need to add code to CustomModule to append the footer content to each processed ASP.NET page. Which code segment should you use?

  1. public CustomModule(HttpApplication app) {app.EndRequest += new EventHandler(app_EndRequest); } void app_EndRequest(object sender, EventArgs e) {HttpApplication app = sender as HttpApplication;app.Response.Write(footerContent); }
  2. public void Init(HttpApplication app) {app.EndRequest += new EventHandler(app_EndRequest); } void app_EndRequest(object sender, EventArgs e) {HttpApplication app = new HttpApplication();app.Response.Write(footerContent); }
  3. public CustomModule() {HttpApplication app = new HttpApplication();app.EndRequest += new EventHandler(app_EndRequest); } void app_EndRequest(object sender, EventArgs e) {HttpApplication app = sender as HttpApplication;app.Response.Write(footerContent); }
  4. public void Init(HttpApplication app) {app.EndRequest += new EventHandler(app_EndRequest); } void app_EndRequest(object sender, EventArgs e) {HttpApplication app = sender as HttpApplication;app.Response.Write(footerContent); }

Correct Answer: 4


Question: You are implementing an ASP.NET Web site. The root directory of the site contains a page named Error.aspx. You need to display the Error.aspx page if an unhandled error occurs on any page within the site. You also must ensure that the original URL in the browser is not changed. What should you do?

  1. Add the following configuration to the web.config file. <system.web><customErrors mode=”On”><error statusCode=”500″ redirect=”~/Error.aspx” /></customErrors> </system.web>
  2. Add the following configuration to the web.config file. <system.web><customErrors redirectMode=”ResponseRewrite”mode=”On” defaultRedirect=”~/Error.aspx” /> </system.web>
  3. Add the following code segment to the Global.asax file. void Application_Error(object sender, EventArgs e) {Response.Redirect(“~/Error.aspx”); }
  4. Add the following code segment to the Global.asax file. void Page_Error(object sender, EventArgs e) {Server.Transfer(“~/Error.aspx”); }

Correct Answer: 2


Question: You are implementing an ASP.NET Web site. The site uses a component that must be dynamically configured before it can be used within site pages. You create a static method named SiteHelper.Configure that configures the component. You need to add a code segment to the Global.asax file that invokes the SiteHelper.Configure method the first time, and only the first time, that any page in the site is requested. Which code segment should you use?

  1. void Application_Start(object sender, EventArgs e) {SiteHelper.Configure (); }
  2. void Application_Init(object sender, EventArgs e) {SiteHelper.Configure (); }
  3. void Application_BeginRequest(object sender, EventArgs e) {SiteHelper.Configure (); } Object lockObject = new Object();
  4. void Application_BeginRequest(object sender, EventArgs e) {lock(lockObject){SiteHelper.Configure ();} }

Correct Answer: 1

Tagged . Bookmark the permalink.

Leave a Reply