@{
var host = Url.Content("~/");
}
<script type="text/javascript">
var host = "@host";
$(function () {
if ($("#Company" != null)) {
$("#companyselect").change(function () {
var newuri = host + "eg/" + $("#companyselect option:selected").text() + "/Comps";
window.location.url = newuri;
}
);
}
});
</script>
newuri = / bo / eg / airline inc / 5
但浏览器始终重定向到 / eg / airline inc / 5
答案 0 :(得分:0)
可能是你错过了主机名吗?在您当前的设置中,主机名看起来只会评估为“/”;
例如,您可以尝试:
var host = window.location.hostname;
var newuri = host + "/eg/" + $("#companyselect option:selected").text() + "/Comps";
window.location.url = newuri;