コード例 #1
0
        public async Task <ActionResult> Page(string url)
        {
            var model = new PageViewModel();

            if (String.IsNullOrWhiteSpace(url))
            {
                model.Content = String.Empty;
            }
            else
            {
                try {
                    var uriBase     = HttpContext.Request.Url;
                    var proxyPrefix = new Uri(uriBase, "/Page?url=").ToString();

                    model.Content = await _substituteProxyService.GetSubstitutePage(
                        url, new Headers(HttpContext), proxyPrefix);
                }
                catch (UriFormatException ufe) {
                    model.Content = ufe.Message;
                }
                catch (NotSupportedException nse) {
                    model.Content = nse.Message;
                }
                catch (HttpRequestException rex) {
                    model.Content = rex.Message;
                }
                catch (Exception e) {
                    model.Content = "Something went wrong while displaying this webpage";
                }
            }
            return(View("Page", model));
        }