ASP. net mvc detects the browser version and prompts you to download the updated version.
Some browser versions may not support html5, css3, and adaptive features. In this case, you need to remind the viewer to update the browser version to the latest version.
The plug-in used in this article is: http://jreject.turnwheel.com/
HomeController:
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
}
In Shared/_ Layout. cshtml:
<!DOCTYPE html>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>@ViewBag.Title</title>
@Styles.Render("~/Content/css")
@RenderSection("styles", required: false)
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")
<body>
@RenderBody()
@RenderSection("scripts", required: false)
</body>
In Home/Index. cshtml:
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@section styles
{
<link href="~/jReject/css/jquery.reject.css" rel="stylesheet" />
<style type="text/css">
</style>
}
@section scripts
{
<script src="~/jReject/js/jquery.reject.js"></script>
<script type="text/javascript">
$(function() {
needDownloadNewExplorer();
});
function needDownloadNewExplorer() {
setTimeout(function () {
$.reject({
reject: {
safari: true, // Apple Safari
chrome: true, // Google Chrome
firefox: true, // Mozilla Firefox
msie: true, // Microsoft Internet Explorer
opera: true, // Opera
konqueror: true, // Konqueror (Linux)
unknown: true // Everything else
},
imagePath: './jReject/images/',
browserInfo: { // Settings for which browsers to display
chrome: {
// Text below the icon
text: 'Google Chrome',
// URL For icon/text link
url: 'http://rj.baidu.com/soft/detail/14744.html',
// (Optional) Use "allow" to customized when to show this option
// Example: to show chrome only for IE users
// allow: { all: false, msie: true }
},
firefox: {
text: 'Mozilla Firefox',
url: 'http://rj.baidu.com/soft/detail/11843.html'
},
safari: {
text: 'Safari',
url: 'http://www.apple.com/safari/download/'
},
opera: {
text: 'Opera',
url: 'http://www.opera.com/download/'
},
msie: {
text: 'Internet Explorer',
url: 'http://www.microsoft.com/windows/Internet-explorer/'
}
},
CloseLink: 'close this Windows ',
Header: 'If this page shows a problem, please download the latest version of the following browser ', // Header Text
paragraph1: '', // Paragraph 1
paragraph2: '',
closeMessage: '' // Message below close window link
}); // Customized Browsers
}, 2000);
}
</script>
}
The effect is as follows: