【问题标题】:Reading base path from web.config从 web.config 读取基本路径
【发布时间】:2019-07-22 18:13:46
【问题描述】:

我有一个用 MVC5/C# 创建的 Web 应用程序

应用程序使用 jscript 从控制器调用某些实例的操作。我遇到的问题是应用程序在 IIS 上的嵌套比在我的本地服务器上更深。

本地:

var urlForModesl = "/ICS_Requisitions/Details";

IIS

var urlForModesl = "../ICS_Requisitions/Details";

无论如何我可以动态获取基本路径。 .也许来自 web.config 之类的?这样我就不必一直来回切换。这使得测试有点麻烦,因为在整个应用程序中都有类似的情况。

【问题讨论】:

    标签: c# asp.net-mvc-5 jscript


    【解决方案1】:

    你试过捆绑 Js.如果不按照这个

    // create an object of ScriptBundle and 
            // specify bundle name (as virtual path) as constructor parameter 
            ScriptBundle scriptBndl = new ScriptBundle("~/bundles/bootstrap");
    
    
            //use Include() method to add all the script files with their paths 
            scriptBndl.Include(
                                "~/Scripts/bootstrap.js",
                                "~/Scripts/respond.js"
                              );
    
    
            //Add the bundle into BundleCollection
            bundles.Add(scriptBndl);
    
            BundleTable.EnableOptimizations = true;
    

    在此链接上查找更多详细信息

    https://www.tutorialsteacher.com/mvc/scriptbundle-mvc

    【讨论】:

      猜你喜欢
      • 2018-08-13
      • 1970-01-01
      • 1970-01-01
      • 2011-07-15
      • 1970-01-01
      • 2018-01-22
      • 2017-05-16
      • 2010-12-26
      • 2014-10-10
      相关资源
      最近更新 更多