프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / ConvertService / ServiceBase / UploadFonts / ViewSwitcher.ascx.cs @ 950e6b84

이력 | 보기 | 이력해설 | 다운로드 (1.55 KB)

1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Web;
5
using System.Web.Routing;
6
using System.Web.UI;
7
using System.Web.UI.WebControls;
8
using Microsoft.AspNet.FriendlyUrls.Resolvers;
9

    
10
namespace UploadFonts
11
{
12
    public partial class ViewSwitcher : System.Web.UI.UserControl
13
    {
14
        protected string CurrentView { get; private set; }
15

    
16
        protected string AlternateView { get; private set; }
17

    
18
        protected string SwitchUrl { get; private set; }
19

    
20
        protected void Page_Load(object sender, EventArgs e)
21
        {
22
            // Determine current view
23
            var isMobile = WebFormsFriendlyUrlResolver.IsMobileView(new HttpContextWrapper(Context));
24
            CurrentView = isMobile ? "Mobile" : "Desktop";
25

    
26
            // Determine alternate view
27
            AlternateView = isMobile ? "Desktop" : "Mobile";
28

    
29
            // Create switch URL from the route, e.g. ~/__FriendlyUrls_SwitchView/Mobile?ReturnUrl=/Page
30
            var switchViewRouteName = "AspNet.FriendlyUrls.SwitchView";
31
            var switchViewRoute = RouteTable.Routes[switchViewRouteName];
32
            if (switchViewRoute == null)
33
            {
34
                // Friendly URLs is not enabled or the name of the switch view route is out of sync
35
                this.Visible = false;
36
                return;
37
            }
38
            var url = GetRouteUrl(switchViewRouteName, new { view = AlternateView, __FriendlyUrls_SwitchViews = true });
39
            url += "?ReturnUrl=" + HttpUtility.UrlEncode(Request.RawUrl);
40
            SwitchUrl = url;
41
        }
42
    }
43
}
클립보드 이미지 추가 (최대 크기: 500 MB)