Solved

how do i specify master page programtically under asp.net mvc 4

Posted on 2014-12-30
1
141 Views
Last Modified: 2015-01-01
how do i specify the master page programtically,for example,i'd like main page goes to a out of service from 8:00 pm to 8:00am,& set a filter out of service  from 8:00 pm to 8:00am as well.in addtion ,i have a ip database api,i'd like restrict the ip only from my country to access,otherwise the main page goest to "bad request" page.how do i do this programtically?
many thanks & best regards
ken
0
Comment
Question by:ken yup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 25

Accepted Solution

by:
apeter earned 500 total points
ID: 40525177
You can check below 2 conditions in one place.

1. Timing
2. Ip from ips database

put this code block in the Application_BeginRequest of the Global.asax

void Application_BeginRequest(object sender, EventArgs e)
      {
          if (DateTime.Now <is greater than 8 am and lesser than 8 pm>) AND (Request.UserHostAddress <is in your ip datadatabase>)) //replace the <text> to a c sharp syntax
          {
              if (!Request.IsLocal)
              {
                  HttpContext.Current.RewritePath("<Your Maintenance Page >");
              }
          }
      }
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question