ASP.NET core exampleThis example shows how to:
- Set up configuration options to add elements to the 51Degrees Pipeline. {"PipelineOptions": {"Elements": [{"BuilderName": "math"},{"BuilderName": "JavaScriptBundlerElement"}],"ClientSideEnabled": true}}
- Configure client-side code to be run by enabling it in the Web.config.
- Use the results contained in the
Request.Browser
instance to display something on a page view.public class HomeController : Controller{...public IActionResult Index(){ViewData["Message"] =Request.Browser["math.operation"] + " = " + Request.Browser["math.result"];return View();}...
Controller
/* ********************************************************************
* Copyright (C) 2019 51Degrees Mobile Experts Limited.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* ******************************************************************** */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Example_Framework_Website.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
ViewData["Message"] =
Request.Browser["math.operation"] +
" = " +
Request.Browser["math.result"];
return View();
}
}
}