Solved

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

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Json POSt to Rest API 4 60
Server Error 11 58
Connection String 16 54
Importing CSV file encoded in UTF-8 in SQL SERVER 2008 using BULK INSERT 5 50
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

786 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