小编rog*_*ito的帖子

捆绑的css链接收到404错误

我正在尝试捆绑在ASP.NET MVC 4中工作.我从为捆绑的CSS生成的链接中收到404错误.我做了以下事情:

  1. 通过NuGet安装"Microsoft ASP.NET Web Optimization Framework"软件包(v4.0.20710.0)

  2. 在App_Start目录中创建了一个BundleConfig类,其中包含以下内容:

    using System.Web.Optimization;
    namespace BsdAppTemplate.Web_Nancy.App_Start
    {
        public class BundleConfig
        {
            public static void RegisterBundles(BundleCollection bundles)
            {
                bundles.Add(new StyleBundle("~/bundles/styles/cvi").Include(
                    "~/mainstyles.css"
                ));
            }
        }
    }
    
    Run Code Online (Sandbox Code Playgroud)
  3. 在站点根目录的Web.config中添加了以下内容:

    <system.web>
        <compilation debug="false" targetFramework="4.5" />
    
        <pages>
          <namespaces>
            <add namespace="System.Web.Optimization"/>
            ...
          </namespaces>
        </pages>
    </system.web>
    
    Run Code Online (Sandbox Code Playgroud)
  4. 将以下内容添加到我的MVC布局文件的head元素中:

     @Styles.Render("~/bundles/styles/cvi")
    
    Run Code Online (Sandbox Code Playgroud)
  5. 将BundleConfig("mainstyles.css")中引用的CSS文件复制到我的Web项目的根目录中.

当我查看渲染文件的来源时,我可以看到链接显示为:

<link href="/bundles/styles/cvi" rel="stylesheet"/>
Run Code Online (Sandbox Code Playgroud)

此链接在浏览时会生成404,或在Chrome的网络标签中查看页面请求.

我也尝试过Web表单上的等价物,但是从添加时生成的链接中得到了相同的结果(404):

<%: Styles.Render("~/bundles/styles/cvi") %>
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-mvc bundle asp.net-mvc-4

22
推荐指数
4
解决办法
2万
查看次数

带有Selenium的Chromedriver远程调试端口

我正在使用Capybara Selenium运行无头Chrome,这很好用,但我无法弄清楚如何使用远程调试。当我添加--remote-debugging-port=4444--remote-debugging-port=9222或时--remote-debugging-port=9521,Selenium不再连接到浏览器以运行测试。

如何使远程调试工作?这是我的代码供参考:

Capybara.register_driver :selenium do |app|
  # from https://github.com/SeleniumHQ/selenium/issues/3738
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(loggingPrefs: {browser: 'ALL'})
  options = Selenium::WebDriver::Chrome::Options.new
  options.add_argument '--disable-infobars' # hide info bar about chrome automating test
  # if we don't use this flag, every selenium test will die with the error:
  # "unknown error: Chrome failed to start: exited abnormally"
  options.add_argument '--no-sandbox'
  # BREAKS THINGS if uncommented
  # options.add_argument '--remote-debugging-port=4444'
  options.add_argument '--headless'
  options.add_argument '--window-size=1600,2400'
  options.add_preference('profile.default_content_settings.popups', 0)
  options.add_preference('download.default_directory', DownloadHelpers::PATH.to_s)
  Capybara::Selenium::Driver.new(
    app,
    clear_local_storage: true, …
Run Code Online (Sandbox Code Playgroud)

ruby selenium selenium-chromedriver google-chrome-headless

3
推荐指数
2
解决办法
4082
查看次数

配置structuremap以使用工厂类创建实例

我想配置structuremap以使用工厂类创建服务.工厂本身具有需要填充的依赖性.目前我的Registry类中有以下内容:

For<IDoStuffWebService>().Singleton().Use(() => 
    new DoStuffWebServiceClientFactory(new ConfigProvider()).Create()
);
Run Code Online (Sandbox Code Playgroud)

而不是必须硬编码具体类型DoStuffWebServiceClientFactory并手动填充它的依赖项,我希望structuremap为我得到它(它实现了IDoStuffWebServiceClientFactory).看起来IContext可能有所帮助(http://docs.structuremap.net/UsingSessionContext.htm),但我很难弄清楚这是如何适合的.

任何帮助非常感谢.罗杰.

structuremap

2
推荐指数
1
解决办法
2360
查看次数