예제 #1
0
        public HttpResponse View(object viewModel = null, [CallerMemberName] string viewPath = null)
        {
            var viewContent = System.IO.File.ReadAllText("Views/" +
                                                         this.GetType().Name.Replace("Controller", string.Empty) + "/" +
                                                         viewPath + ".cshtml");

            viewContent = viewEngine.GetHtml(viewContent, viewModel);

            var responseHtml = PutViewInLayout(viewContent, viewModel);

            var responseBodyBytes = Encoding.UTF8.GetBytes(responseHtml);
            var response          = new HttpResponse("text/html", responseBodyBytes);

            return(response);
        }
예제 #2
0
        public HttpResponse View(object viewModel = null, [CallerMemberName] string viewPath = null)
        {
            var layout = System.IO.File.ReadAllText("Views/Shared/_Layout.cshtml");

            layout = layout.Replace("@RenderBody()", "___VIEW_GOES_HERE___");
            layout = viewEngine.GetHtml(layout, viewModel);

            var viewContent = System.IO.File.ReadAllText("Views/" +
                                                         this.GetType().Name.Replace("Controller", string.Empty) + "/" +
                                                         viewPath + ".cshtml");

            viewContent = viewEngine.GetHtml(viewContent, viewModel);

            var responseHtml = layout.Replace("___VIEW_GOES_HERE___", viewContent);

            var responseBodyBytes = Encoding.UTF8.GetBytes(responseHtml);
            var response          = new HttpResponse("text/html", responseBodyBytes);

            return(response);
        }
예제 #3
0
        protected HttpResponse View(object viewModel = null, [CallerMemberName] string path = null)
        {
            var main = System.IO.File.ReadAllText("Views/Shared/_Layout.html");

            main = main.Replace("@RenderBody()", "__VIEW__");
            main = viewEngine.GetHtml(main, viewModel, this.GetUserId());

            var viewContent = System.IO.File.ReadAllText("Views/" + this.GetType().Name.Replace("Controller", string.Empty) + "/" + path + ".html");

            viewContent = this.viewEngine.GetHtml(viewContent, viewModel, this.GetUserId());
            var responseHtml = main.Replace("__VIEW__", viewContent);

            var responseBody = Encoding.UTF8.GetBytes(responseHtml);

            var response = new HttpResponse("text/html", responseBody);

            return(response);
        }