Solved

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

Posted on 2014-12-30
1
134 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
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Library to convert HTML to PDF. 8 46
Round up to 100% in .NET 10 46
Events in static methods 3 31
COnsume rest client 6 15
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now