MVC4 应用程序中未加载图像、CSS 和 JS

2023-12-28

我刚刚将一个新的 MVC4 应用程序部署到我的服务器,但某些 CSS、JS 和图像未加载。例如,Chrome 控制台显示:

加载资源失败:服务器响应状态为500 (内部服务器错误)http://beta.vinformative.com/Content/themes/base/jquery-ui-1.8.20.custom.css http://beta.vinformative.com/Content/themes/base/jquery-ui-1.8.20.custom.css

加载资源失败:服务器响应状态为500 (内部服务器错误)http://beta.vinformative.com/Content/select2.css http://beta.vinformative.com/Content/select2.css

无法加载资源:服务器响应状态为 500(内部服务器 错误)http://beta.vinformative.com/Scripts/Plugins/select2.js http://beta.vinformative.com/Scripts/Plugins/select2.js

无法加载资源:服务器响应状态为 500(内部 服务器错误)http://beta.vinformative.com/Scripts/WineCreate.js http://beta.vinformative.com/Scripts/WineCreate.js

加载资源失败:服务器响应状态为500 (内部服务器错误)http://beta.vinformative.com/Content/images/logo_revisedsmall.png http://beta.vinformative.com/Content/images/logo_revisedsmall.png

它们都可以在服务器上提到的位置上找到。我整夜都在解决其他问题,所以我的眼睛有点模糊,也许我错过了一些明显的东西。您可以在主页上看到这些错误beta.vinformative.com http://beta.vinformative.com以及。

Here is a screenshot of my file layout too from the server: enter image description here

我正在使用捆绑并以发布模式将站点发布到文件系统,但我不希望这会影响图像,不是吗?我将继续这样做,但任何帮助将不胜感激!谢谢!

根据要求编辑捆绑配置:谢谢!

    public class BundleConfig
{
    // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/Libraries/jquery-{version}.js",
                    "~/Scripts/Plugins/jquery.loaderbutton.js",
                    "~/Scripts/Plugins/jquery.form.js"));

        bundles.Add(new ScriptBundle("~/bundles/base").Include(
                    "~/Scripts/Feedback.js",
                    "~/Scripts/Global.js",
                    "~/Scripts/WineSearch.js"
            ));

        bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
                    "~/Scripts/Libraries/jquery-ui-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/Libraries/jquery.validate*"));

        bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                "~/Scripts/bootstrap/bootstrap.js",
                "~/Scripts/bootstrap/bootbox.js",
                "~/Scripts/bootstrap/bootstrap-notify.js"
            ));

        bundles.Add(new ScriptBundle("~/bundles/formhelpers").Include(
                "~/Scripts/bootstrap/Form Helpers/bootstrap-formhelpers-countries.js",
                "~/Scripts/bootstrap/Form Helpers/bootstrap-formhelpers-countries.en_US.js",
                "~/Scripts/bootstrap/Form Helpers/bootstrap-formhelpers-phone.js",
                "~/Scripts/bootstrap/Form Helpers/bootstrap-formhelpers-phone.format.js",
                "~/Scripts/bootstrap/Form Helpers/bootstrap-formhelpers-states.js",
                "~/Scripts/bootstrap/Form Helpers/bootstrap-formhelpers-states.en_US.js"
            ));

        bundles.Add(new ScriptBundle("~/bundles/winedetails").Include(
            "~/Scripts/WineDetails.js",
            "~/Scripts/Plugins/jquery.uploadifive.js",
            "~/Scripts/Plugins/jquery.fileDownload.js",
            "~/Scripts/Plugins/jquery.fancybox.js",
            "~/Scripts/Plugins/jquery.fancybox-media.js",
            "~/Scripts/Plugins/jquery.nailthumb.1.1.js",
            "~/Scripts/Plugins/jquery.lazyload.js"
            ));
        // Use the development version of Modernizr to develop with and learn from. Then, when you're
        // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-*"));

        bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css", "~/Content/slideout.css"));

        bundles.Add(new StyleBundle("~/Content/themes/bootstrap/css").Include(
                "~/Content/themes/bootstrap/bootstrap.css",
                "~/Content/themes/bootstrap/bootstrap-responsive.css",
                "~/Content/themes/bootstrap/bootstrapSwitch.css",
                "~/Content/themes/bootstrap/bootstrap-notify.css",
                "~/Content/themes/bootstrap/bootstrap-formhelpers.css"
            ));

        bundles.Add(new StyleBundle("~/Content/datatables").Include(
            "~/Content/jquery.dataTables.css",
            "~/Content/jquery.dataTables_themeroller.css"));

        bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/chosen.css"));

        bundles.Add(new StyleBundle("~/Content/sitewide").Include(
                "~/Content/themes/base/jquery.ui.autocomplete.css",
                "~/Content/Site.css"
            ));

        bundles.Add(new StyleBundle("~/Content/winedetails").Include(
                "~/Content/uploadifive.css",
                "~/Content/themes/fancybox/jquery.fancybox.css"
            ));

        bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
                    "~/Content/themes/base/jquery.ui.core.css",
                    "~/Content/themes/base/jquery.ui.resizable.css",
                    "~/Content/themes/base/jquery.ui.selectable.css",
                    "~/Content/themes/base/jquery.ui.accordion.css",
                    "~/Content/themes/base/jquery.ui.autocomplete.css",
                    "~/Content/themes/base/jquery.ui.button.css",
                    "~/Content/themes/base/jquery.ui.dialog.css",
                    "~/Content/themes/base/jquery.ui.slider.css",
                    "~/Content/themes/base/jquery.ui.tabs.css",
                    "~/Content/themes/base/jquery.ui.datepicker.css",
                    "~/Content/themes/base/jquery.ui.progressbar.css",
                    "~/Content/themes/base/jquery.ui.theme.css"));


    }
}

EDIT # 2

我尝试更改 _layout 视图中的引用,但没有成功:

from

    <link href="../../Content/themes/base/jquery-ui-1.8.20.custom.css" rel="stylesheet"

to

<link href="@Url.Content("~/Content/themes/base/jquery-ui-1.8.20.custom.css")" rel="stylesheet">

编辑 #3 Web.config

    <?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <sectionGroup name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection, DotNetOpenAuth.Core">
      <section name="messaging" type="DotNetOpenAuth.Configuration.MessagingElement, DotNetOpenAuth.Core" requirePermission="false" allowLocation="true" />
      <section name="reporting" type="DotNetOpenAuth.Configuration.ReportingElement, DotNetOpenAuth.Core" requirePermission="false" allowLocation="true" />
      <section name="openid" type="DotNetOpenAuth.Configuration.OpenIdElement, DotNetOpenAuth.OpenId" requirePermission="false" allowLocation="true" />
      <section name="oauth" type="DotNetOpenAuth.Configuration.OAuthElement, DotNetOpenAuth.OAuth" requirePermission="false" allowLocation="true" />
    </sectionGroup>
    <sectionGroup name="elmah">
      <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
      <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
      <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
      <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
    </sectionGroup>
    <section name="web.optimization" type="Web.Optimization.Configuration.OptimizationSection" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  </configSections>
  <connectionStrings>
    <add name="Elmah" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=elmah;Integrated Security=True" providerName="System.Data.SqlClient" />
    <add name="vfContext" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=vf3;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <customErrors mode="On" defaultRedirect="~/Error/Generic">
      <error statusCode="404" redirect="~/Error/NotFound" />
      <error statusCode="500" redirect="~/Error/internal" />
    </customErrors>
    <compilation debug="true" targetFramework="4.0" />
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" />
    </authentication>
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
    <httpModules>
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
    </httpModules>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
    <remove name="BundleModule" />
    <add name="BundleModule" type="System.Web.Optimization.BundleModule" />
    </modules>
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
    <staticContent>
      <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
      <mimeMap fileExtension=".m4v" mimeType="video/m4v" />
      <mimeMap fileExtension=".ogg" mimeType="video/ogg" />
      <mimeMap fileExtension=".ogv" mimeType="video/ogg" />
      <mimeMap fileExtension=".webm" mimeType="video/webm" />
      <mimeMap fileExtension=".oga" mimeType="audio/ogg" />
      <mimeMap fileExtension=".spx" mimeType="audio/ogg" />
      <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
      <mimeMap fileExtension=".svgz" mimeType="image/svg+xml" />
      <remove fileExtension=".eot" />
      <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
      <mimeMap fileExtension=".otf" mimeType="font/otf" />
      <mimeMap fileExtension=".woff" mimeType="font/x-woff" />
      <remove fileExtension=".manifest" />
      <mimeMap fileExtension=".manifest" mimeType="text/cache-manifest" />
    </staticContent>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="RazorEngine" publicKeyToken="9ee697374c7e744a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.8.0" newVersion="3.0.8.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <legacyHMACWarning enabled="0" />
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>
  <system.net>
    <defaultProxy enabled="true" />
    <mailSettings>
      <smtp from="[email protected] /cdn-cgi/l/email-protection">
        <network host="smtp.emailsrvr.com" port="2525" userName="[email protected] /cdn-cgi/l/email-protection" password="vinf0rmat1ve" />
      </smtp>
    </mailSettings>
    <settings>
      <!-- This setting causes .NET to check certificate revocation lists (CRL) 
                 before trusting HTTPS certificates.  But this setting tends to not 
                 be allowed in shared hosting environments. -->
      <!--<servicePointManager checkCertificateRevocationList="true"/>-->
    </settings>
  </system.net>
  <dotNetOpenAuth>
    <messaging>
      <untrustedWebRequest>
        <whitelistHosts>
          <!-- Uncomment to enable communication with localhost (should generally not activate in production!) -->
          <!--<add name="localhost" />-->
        </whitelistHosts>
      </untrustedWebRequest>
    </messaging>
    <!-- Allow DotNetOpenAuth to publish usage statistics to library authors to improve the library. -->
    <reporting enabled="true" />
    <openid>
      <relyingParty>
        <security requireSsl="false">
          <!-- Uncomment the trustedProviders tag if your relying party should only accept positive assertions from a closed set of OpenID Providers. -->
          <!--<trustedProviders rejectAssertionsFromUntrustedProviders="true">
                        <add endpoint="https://www.google.com/accounts/o8/ud" />
                    </trustedProviders>-->
        </security>
        <behaviors>
          <!-- The following OPTIONAL behavior allows RPs to use SREG only, but be compatible
                         with OPs that use Attribute Exchange (in various formats). -->
          <add type="DotNetOpenAuth.OpenId.RelyingParty.Behaviors.AXFetchAsSregTransform, DotNetOpenAuth.OpenId.RelyingParty" />
        </behaviors>
      </relyingParty>
    </openid>
  </dotNetOpenAuth>
  <uri>
    <!-- The uri section is necessary to turn on .NET 3.5 support for IDN (international domain names),
             which is necessary for OpenID urls with unicode characters in the domain/host name.
             It is also required to put the Uri class into RFC 3986 escaping mode, which OpenID and OAuth require. -->
    <idn enabled="All" />
    <iriParsing enabled="true" />
  </uri>
  <elmah>
    <!--
        See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for 
        more information on remote access and securing ELMAH.
    -->
    <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="Elmah"></errorLog>
    <errorMail from="[email protected] /cdn-cgi/l/email-protection" to="[email protected] /cdn-cgi/l/email-protection" subject="ELMAH Error Log Mail"></errorMail>
    <security allowRemoteAccess="false" />
  </elmah>
  <location path="elmah.axd" inheritInChildApplications="false">
    <system.web>
      <httpHandlers>
        <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
      </httpHandlers>
      <!-- 
        See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for 
        more information on using ASP.NET authorization securing ELMAH.

      <authorization>
        <allow roles="admin" />
        <deny users="*" />  
      </authorization>
      -->
    </system.web>
    <system.webServer>
      <handlers>
        <add name="ELMAH" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
      </handlers>
    </system.webServer>
  </location>
  <web.optimization>
    <bundles>
      <bundle virtualPath="~/Content/sample" transform="System.Web.Optimization.JsMinify, System.Web.Optimization">
        <content>
          <!-- Add some single files -->
          <!-- <add path="~/Scripts/validation.js" /> -->
          <!-- <add path="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js" /> -->
          <!-- Add a directory (and its subdirectories) -->
          <!-- <add path="~/Scripts/Plugins" searchPattern="*.js" searchSubdirectories="true" /> -->
        </content>
        <!--
        If you want to apply multiple transformations, 
        you should remove the "transform" attribute from the bundle. 
        -->
        <!--
        <transformations>
          <add type="Web.Optimization.Bundles.CoffeeScript.CoffeeScriptTransform, Web.Optimization.Bundles.CoffeeScript" />
          <add type="System.Web.Optimization.JsMinify, System.Web.Optimization" />
        </transformations>
        -->
      </bundle>
    </bundles>
  </web.optimization>
</configuration>

只有非捆绑的 CSS 和 JS 以及 img 标签不会呈现。

FIXED! 我在我的节点中注释掉了以下内容:

  <staticContent>
        <!-- <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
      <mimeMap fileExtension=".m4v" mimeType="video/m4v" />
      <mimeMap fileExtension=".ogg" mimeType="video/ogg" />
      <mimeMap fileExtension=".ogv" mimeType="video/ogg" />
      <mimeMap fileExtension=".webm" mimeType="video/webm" />
      <mimeMap fileExtension=".oga" mimeType="audio/ogg" />
      <mimeMap fileExtension=".spx" mimeType="audio/ogg" />
      <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
      <mimeMap fileExtension=".svgz" mimeType="image/svg+xml" />
      <remove fileExtension=".eot" />
      <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
      <mimeMap fileExtension=".otf" mimeType="font/otf" />
      <mimeMap fileExtension=".woff" mimeType="font/x-woff" />-->
      <remove fileExtension=".manifest" />
      <mimeMap fileExtension=".manifest" mimeType="text/cache-manifest" />
    </staticContent>

在 web.config 中的 system.webserver 下注释掉这个

  <staticContent>
        <!-- <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
      <mimeMap fileExtension=".m4v" mimeType="video/m4v" />
      <mimeMap fileExtension=".ogg" mimeType="video/ogg" />
      <mimeMap fileExtension=".ogv" mimeType="video/ogg" />
      <mimeMap fileExtension=".webm" mimeType="video/webm" />
      <mimeMap fileExtension=".oga" mimeType="audio/ogg" />
      <mimeMap fileExtension=".spx" mimeType="audio/ogg" />
      <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
      <mimeMap fileExtension=".svgz" mimeType="image/svg+xml" />
      <remove fileExtension=".eot" />
      <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
      <mimeMap fileExtension=".otf" mimeType="font/otf" />
      <mimeMap fileExtension=".woff" mimeType="font/x-woff" />-->
      <remove fileExtension=".manifest" />
      <mimeMap fileExtension=".manifest" mimeType="text/cache-manifest" />
    </staticContent>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

MVC4 应用程序中未加载图像、CSS 和 JS 的相关文章

  • 使用 Ajax Jquery post 请求进行 Json 劫持

    昨天 我读了一些关于如何预防的好文章使用 Asp Net MVC 进行 Json 劫持 http haacked com archive 2009 06 24 json hijacking aspx 规则是 永远不要通过 get 请求发送
  • 如何在类文件中使用 Url.Action() ?

    如何在 MVC 项目的类文件中使用 Url Action Like namespace 3harf public class myFunction public static void CheckUserAdminPanelPermissi
  • 从 SQLCE 4 迁移到 SQL Server 2008

    因此 作为早期采用者 我开发了一个基于 SQLCE4 ASP Net MVC3 和实体框架CTP5 http www microsoft com downloads en details aspx FamilyID 35adb688 f8a
  • 从 ASP.NET MVC 将 HTML 表导出到 Excel

    我目前正在使用 ASP NET MVC 并且有一个操作方法 可以在视图中以表格格式显示一些报告 我需要通过单击视图中的按钮将同一个表导出到 Excel 文档 如何才能实现这一目标 您将如何为此创建 Action 方法 在您的控制器操作中 您
  • SQL Server中主键和唯一索引的区别[重复]

    这个问题在这里已经有答案了 我的公司目前正在重写我们最近获得的一个应用程序 我们选择使用 ASP net mvc4 来构建这个系统 并使用实体框架作为我们的 ORM 我们收购的公司的前任所有者非常坚定地要求我们使用他们的旧数据库 并且不对其
  • MVC 4 使用 Ajax.BeginForm() 从另一个局部视图更新局部视图

    我在其中一个页面上设置了评论部分 父视图有一个部分视图 它显示该 ID 的评论 并提供显示另一个部分视图以发布评论的选项 当有人发表评论时 我希望父级中的第一个部分视图刷新以显示新评论 目前 当您单击发表评论时 将调用 AddComment
  • 在 ASP.NET MVC 中使用 MySQL 的 AccountController

    在 Visual Studio 中创建默认的 ASP NET MVC 项目会设置一个可以在其中注册用户的基本项目 我将如何继续更改它以使用 MySQL 服务器而不是 SQLServer 现在可以使用了 安装最新的 Connector NET
  • ASP.NET MVC:FileStreamResult 返回太多字节?

    我正在调用 MVC 控制器方法 返回类型是FileStreamResult 在此方法中 我以字节数组的形式创建图像 我正在创建一个 MemoryStream 在构造函数中传递字节数组 然后 我在构造函数中返回一个新的 FileStreamR
  • 当视图模型类型为包含超过 4 个项目的元组时,Asp.net mvc 2 .net 4.0 出现错误

    当我在 Asp net mvc 2 net 4 0 中使用模型类型 Tuple 创建强类型视图时 当 Tuple 具有超过 4 个项目时 我会收到错误 示例1 视图类型是Tuple
  • ASP.NET MVC - 更新生产中的预编译 Razor View 文件

    我想知道以下是否可能 通过在 Visual Studio 中打开项目设置 使用我们的 MVC 应用程序预编译 Razor 视图 将应用程序部署到生产环境 然后在稍后阶段 通过覆盖生产中现有的 cshtml 文件来更新视图 而无需回收应用程序
  • 使用ViewData或不使用ViewData

    我一直在阅读 Professional ASP NET MVC 1 0 一书 并阅读其他有关从控制器到视图中使用 ViewModel 而不是 ViewData 的资料 但后来我看到很多 ViewData 的例子都被用在一些困难的场景中 除了
  • MVC3数据缓存技术

    我有一个 sql 查询 存储过程 在结果显示在网络网格中之前需要大约 8 10 秒才能返回 关于 asp net mvc3 中的缓存的性能最佳实践是什么 以便用户不必每次都花费 8 10 秒来加载该数据 减少优化查询 你可以使用内存缓存 h
  • T4MVC Base 控制器没有默认构造函数

    我的控制器是从另一个没有默认构造函数的控制器继承的 T4MVC 生成以下构造函数 假设基本控制器具有默认构造函数 protected MyControllerController Dummy d 我该如何解决这个问题 有趣的是 根据this
  • 将视频上传/保存到数据库或文件系统

    我以前从未尝试过保存视频 所以我对此了解不多 我知道如果视频很小 我可以转换为字节数组并保存到数据库 但是为了提高效率 我想了解如何将任何上传的视频保存到我的服务器文件中 然后只保存该文件的文件路径我的数据库表中的视频 我完全不知道如何开始
  • 调用泛型类的方法

    这是上下文 我尝试编写一个映射器来动态地将域模型对象转换为 ViewModel 对象 我遇到的问题是 当我尝试通过反射调用泛型类的方法时 出现此错误 System InvalidOperationException 无法对 Contains
  • 重定向到其他控制器中的操作

    我想从一个控制器中的操作重定向到第二个控制器中的操作 通常我会使用 RedirectToAction actionName controllerName objects 我想要重定向到的方法有两个重载 一个用于 HttpVerbs Get
  • 如何直接在 Razor 中从 ASP.NET Identity 获取 UserId() 方法

    我的某些部分的自定义授权存在此问题Views 我不想穿上PartialView 而不是我使用If声明如下 if item CurrentComment Id Guid Parse ViewBag UserId repository IsUs
  • 如何构造控制器来对多个条件进行排序 asp.net mvc

    设置控制器按许多 可能为空 标准排序的最佳方法是什么 举例来说 我正在建立一个销售汽车的网站 我的 CarController 有一个函数 Index 它将汽车的 IList 返回到视图 并且每辆车的详细信息都用部分视图呈现 构建这个结构的
  • ASP.NET MVC 防伪造令牌不安全

    在没有 ssl 的情况下向服务器发出请求时 我实际上可以看到 MVC3 框架以纯文本形式生成的验证令牌密钥 该密钥存储在名为 RequestVerificationToken Lw 的 cookie 中 在混合安全环境中 实际上可以在向非
  • 实体框架 - 选择特定列并返回强类型而不丢失强制类型转换

    我正在尝试做类似的事情这个帖子 https stackoverflow com questions 1094931 linq to sql how to select specific columns and return strongly

随机推荐

  • 无法将 DispatcherServlet 映射到上下文根

    这是我用于 spring mvc 的当前配置 1 web xml
  • 我的 C 程序读取一个文本文件。当我将它放入 Xcode 时,它​​失败了。发生了什么?

    我有一个打开 txt 的函数 使用 fscanf 读取格式如下的数字 532 2 234 32 当我使用 GCC 编译时它成功地做到了这一点 但我无法在 Xcode 中打开文件 为什么 相关代码是 int main void FILE in
  • 如何禁用 WinForms DataGrid 中的按钮单元格?

    我有一个 WinForms 应用程序 其中包含一个 DataGridView 控件和一列 DataGridViewButtonCell 单元格 当我单击其中一个按钮时 它会启动一项后台任务 我想禁用这些按钮 直到该任务完成 我可以禁用 Da
  • Gekko 长期性能

    在下面的代码中 全年 PV 斜率优化 每小时时间步长 CSV 数据下载link https drive google com file d 172HaD87t9V PDElMER4MwDaWyuCZ3KA5 view usp sharing
  • 如何在使用rescue_from时使用Rails4和RSpec测试渲染状态:404

    我有一个带有 PagesController 的 Rails4 应用程序 当找不到页面时 show method 会抛出自定义异常 PageNotFoundError 在我定义的控制器之上rescue from PageNotFoundEr
  • 转换输出中不需要的字符编码转换

    我这里有一个情况 JAVA版本1 6 Linux RH 5 6 Tikanga Windows 7 Cygwin最新版本 等级 1 6 在一台机器 Linux 上 当我运行 Gradle 构建时 我得到生成的 xsl 文件 这些文件与我运行
  • iOS:Objective-C 中的事件监听器相当于什么?

    在我的一些学习中 我看到有人提到 在视图控制器中 您可以拥有一个模型 并在模型上有某种监听器来监听其中的变化 我认为我没有使用正确的名称 这可能就是为什么我的搜索没有找到任何结果的原因 本质上 我想将服务器调用从控制器移到我的模型中 但我需
  • 使用 Netty 的多线程 UDP 服务器

    我正在尝试使用 Netty 实现 UDP 服务器 这个想法是只绑定一次 因此只创建一个Channel This Channel仅使用一个处理程序进行初始化 该处理程序通过一个线程在多个线程之间分派传入数据报的处理ExecutorServic
  • Google Drive API 使用浏览器版本创建空的“无标题”文件

    我正在尝试使用 Google Drive API 的 浏览器 版本 它似乎主要遵循 Nodejs 语法 但除了浏览器的第一个 hello world 示例之外 似乎没有太多示例 现在我正在尝试创建一个文件夹 然后在该文件夹内创建一个简单的
  • 当任务计划程序启动时隐藏 C# 控制台应用程序窗口

    我已经在谷歌上搜索了这个并阅读了一些资源 但我无法找到一个好的答案 有谁知道如何防止控制台应用程序窗口在任务计划程序启动时打开 Ref 改变output type to Windows application会解决你的问题 转到 项目 gt
  • 从 XAML 中的 *.resx 文件获取值

    是否可以将资源文件中的某些值直接添加到 XAML 标记中 或者为了本地化 我们总是必须在 cs 文件中制作类似的内容 txtMessage Text Messages WarningUserMessage Where Messages是资源
  • Python、Pandas:使用 GroupBy.groups 描述将其应用于另一个分组

    让我们考虑一个 DataFrame 它在 2010 年 1 月的每一天包含 1 行 2 个值 date range pd date range dt 2010 1 1 dt 2010 1 31 freq 1D df pd DataFrame
  • 如何从 DQL 查询返回对象?

    我在原则 2 中编写了一个 DQL 查询 qb gt select r position gt from Entities Races r gt where qb gt expr gt eq r entrantId entrant id g
  • 如何使用 GraphicsPath 绘制形状来创建自定义控件的区域?

    我目前正在尝试覆盖OnPaint 我正在构建的自定义控件的方法 该对象只是一个简单的面板 但我试图让它看起来不同类型的方式 如下所示 我正在使用 GraphicsPath 来帮助我尝试完成此任务 但它的外观 行为并不像我预期的那样工作 因为
  • Node.js Mongoose.js 字符串到 ObjectId 函数

    是否有一个函数可以使用 mongoose 将字符串转换为节点中的 objectId 架构指定某物是一个 ObjectId 但是当它从字符串保存时 mongo 告诉我它仍然只是一个字符串 例如 对象的 id 显示为objectId blah
  • ggraph的定制图例

    我想创建一个自定义图例 示例图例如下所示 这是我的情节 我使用 ggraph 创建了这个图 在这个情节下或在情节附近的某个地方我想要有我上面提到的图例 有任何想法吗 从技术上讲 您要求使用另一个图作为图例 因此 我们需要安排一个网格并将该图
  • 为 Facebook 对象 ID 而不是 URL 制作一个点赞按钮?

    Facebook点赞按钮上的文档 http developers facebook com docs reference plugins like 允许为 URL 创建 赞 按钮 然而 文档还表明根据对象 ID 记录点赞数 http dev
  • 为什么'int i = i;'合法的? [复制]

    这个问题在这里已经有答案了 可能的重复 int 变量 1 无效主 int i i https stackoverflow com questions 3173462 int var 1 void main int i i 下面的代码在g 和
  • 可以在 ARM 模板中执行嵌套复制循环吗?

    我正在尝试动态生成路径映射 以将传入流量路由到应用程序网关的正确后端池 例如 我们有 20 个租户 每个后端池允许 5 个租户 这意味着我们将生成 4 个后端池 我需要动态创建路径映射 以便后端池一为租户 1 5 提供服务 后端池二为租户
  • MVC4 应用程序中未加载图像、CSS 和 JS

    我刚刚将一个新的 MVC4 应用程序部署到我的服务器 但某些 CSS JS 和图像未加载 例如 Chrome 控制台显示 加载资源失败 服务器响应状态为500 内部服务器错误 http beta vinformative com Conte