.Net MVC4 发布后页面样式问题

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/tai532439904/article/details/77481824
  1. 样式目录由于限制登录未能被加载
    如果网站限制必须登录才能访问网站(例:后台系统),必须在根目录Web.config配置资源目录无需登录.

     <!--页面权限控制-->
            <configuration>
              <location path="Content">
                <system.web>
                  <authorization>
                    <allow users="*"/>
                  </authorization>
                </system.web>
              </location>
              <location path="Scripts">
                <system.web>
                  <authorization>
                    <allow users="*"/>
                  </authorization>
                </system.web>
              </location>
    
              <!-- 注意:这个目录虽然项目没这个目录,但是由于BundleConfig中设置js集目录别名
              路径为bundles开头,所以发布后页面源码中路径也是bundles,所以要把这个目录设置为
              免登陆 -->
              <location path="bundles">
                <system.web>
                  <authorization>
                    <allow users="*"/>
                  </authorization>
                </system.web>
              </location>
              <location path="Images">
                <system.web>
                  <authorization>
                    <allow users="*"/>
                  </authorization>
                </system.web>
              </location>
            </configuration>

    注意: 由于BundleConfig中设置的问题,可能虽然js在Scripts目录中,但是设置的别名路径为其他名,则需要把这个别名路径第一个目录名设置为免登陆.

    Example:

    BundleConfig中设置的路径别名:
    BundleConfig中设置的路径别名

    发布后页面源码显示:
    发布后页面源码显示

    所以需要设置bundles目录为免登陆

  2. CSS样式出错
    查看页面源码,在css顶部出现以下提示:

        /* 未能缩小。正在返回未缩小的内容。
        (2,2-3): run-time warning JS1195: Expected expression: .
        (2,36-37): run-time warning JS1004: Expected ';': :
        (2,85-86): run-time warning JS1004: Expected ';': :
        (2,139-140): run-time warning JS1004: Expected ';': :
        (2,182-183): run-time warning JS1197: Too many errors. The file might not be a JavaScript file: :
     */

    查看系统源码发现BundleConfig中设置导致,css样式用了ScriptBundle导致压缩出错.

    正确格式:
    JS:

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

    CSS:

    bundles.Add(new StyleBundle("~/Content/css/login").Include(
                    "~/Content/global.css",
                    "~/Content/login.css"));
展开阅读全文

MVC4 net4.5 改为 net4.0 后发布问题

10-18

我的环境是VS2012 MVC4开发的一个系统.运行正常.但是发布服务器是WIN2003 iis6.0 支持最高的版本为 net framework 4.0rnrn我开发的环境是net framework 4.5. 改为 net framework 4.0 NuGet的程序包都需要重新安装 我用rnUpdate-Package –reinstall [XXXX] 重新安装了程序包.rnrn我的程序都是一切正常的.net framework 4.5. 改为 net framework 4.0 后生成后没有问题,访问就跳出如下错误.不知道如何解决.rnrnrn[code=html]rn“/”应用程序中的服务器错误。rn--------------------------------------------------------------------------------rnrnrn 未能加载文件或程序集“DotNetOpenAuth.AspNet”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040) rn说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 rnrn异常详细信息: System.IO.FileLoadException: 未能加载文件或程序集“DotNetOpenAuth.AspNet”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)rnrn源错误: rnrnrnrnrn执行当前 Web 请求期间生成了未经处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。rnrnrn程序集加载跟踪: 下列信息有助于确定程序集“DotNetOpenAuth.AspNet”未能加载的原因。rnrnrnrnrnrn=== 预绑定状态信息 ===rn日志: 用户 = DELIXI-ELECTRIC\xiaopeng.chenrn日志: DisplayName = DotNetOpenAuth.AspNetrn (Partial)rn警告: 为程序集提供了部分绑定信息:rn警告: 程序集名称: DotNetOpenAuth.AspNet | 域 ID: 2rn警告: 当仅提供程序集显示名称的一部分时,将发生部分绑定。rn警告: 这可能导致联编程序加载错误的程序集。rn警告: 建议为程序集提供完全指定的文字标识,rn警告: 并由简单名称、版本、区域性和公钥标记组成。rn警告: 有关此问题的详细信息和常见解决方案,请参见白皮书 http://go.microsoft.com/fwlink/?LinkId=109270。rn日志: Appbase = file:///E:/WORK/NPP采购/PRO/AppNpp/AppNpp/rn日志: 初始 PrivatePath = E:\WORK\NPP采购\PRO\AppNpp\AppNpp\binrn调用程序集: (Unknown)。rn===rn日志: 此绑定从 default 加载上下文开始。rn日志: 正在使用应用程序配置文件: E:\WORK\NPP采购\PRO\AppNpp\AppNpp\web.configrn日志: 使用主机配置文件: C:\Users\xiaopeng.chen\Documents\IISExpress\config\aspnet.configrn日志: 使用 C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config 的计算机配置文件。rn日志: 此时没有为引用应用策略(私有、自定义、分部或基于位置的程序集绑定)。rn日志: 尝试下载新的 URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/f70cfd63/24c3f6dc/DotNetOpenAuth.AspNet.DLL。rn日志: 尝试下载新的 URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/f70cfd63/24c3f6dc/DotNetOpenAuth.AspNet/DotNetOpenAuth.AspNet.DLL。rn日志: 尝试下载新的 URL file:///E:/WORK/NPP采购/PRO/AppNpp/AppNpp/bin/DotNetOpenAuth.AspNet.DLL。rn日志: 正在使用应用程序配置文件: E:\WORK\NPP采购\PRO\AppNpp\AppNpp\web.configrn日志: 使用主机配置文件: C:\Users\xiaopeng.chen\Documents\IISExpress\config\aspnet.configrn日志: 使用 C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config 的计算机配置文件。rn日志: 在应用程序配置文件中找到重定向: 4.0.0.0 已重定向到 4.1.0.0。rn日志: 策略后引用: DotNetOpenAuth.AspNet, Version=4.1.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246rn日志: 尝试下载新的 URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/f70cfd63/24c3f6dc/DotNetOpenAuth.AspNet.DLL。rn日志: 尝试下载新的 URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/f70cfd63/24c3f6dc/DotNetOpenAuth.AspNet/DotNetOpenAuth.AspNet.DLL。rn日志: 尝试下载新的 URL file:///E:/WORK/NPP采购/PRO/AppNpp/AppNpp/bin/DotNetOpenAuth.AspNet.DLL。rn警告: 比较程序集名称时发生不匹配: 次版本rn错误: 未能完成程序集的安装(hr = 0x80131040)。探测终止。rn rnrn堆栈跟踪: rnrnrnrnrnrn[FileLoadException: 未能加载文件或程序集“DotNetOpenAuth.AspNet”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)]rnrn[FileLoadException: 未能加载文件或程序集“DotNetOpenAuth.AspNet, Version=4.1.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)]rn System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0rn System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +34rn System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152rn System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77rn System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +16rn System.Reflection.Assembly.Load(String assemblyString) +28rn System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38rnrn[ConfigurationErrorsException: 未能加载文件或程序集“DotNetOpenAuth.AspNet, Version=4.1.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)]rn System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +752rn System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +218rn System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130rn System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170rn System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91rn System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +258rn System.Web.Compilation.BuildManager.ExecutePreAppStart() +135rn System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516rnrn[HttpException (0x80004005): 未能加载文件或程序集“DotNetOpenAuth.AspNet, Version=4.1.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)]rn System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9880168rn System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101rn System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254rn rn[/code] 论坛

WIN7 发布 MVC4 报错

05-13

Server Error in '/' Application.rn--------------------------------------------------------------------------------rnrnCompilation Error rnDescription: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. rnrnCompiler Error Message: CS0016: Could not write to output file 'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\App_global.asax.6rl89b0n.dll' -- '拒绝访问。 'rnrnSource Error:rnrn rnrn[No relevant source lines]rn rnrnSource File: Line: 0 rnrnrnrnShow Detailed Compiler Output:rnrnrnc:\windows\system32\inetsrv> "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe" /t:library /utf8output /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Services\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_64\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\assembly\dl3\e7d6d582\f9b05462_c166d001\Newtonsoft.Json.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activation\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activation.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\assembly\dl3\44a36b13\1978a363_c166d001\System.Web.Optimization.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\assembly\dl3\da2be507\9950ba62_c166d001\System.Web.Mvc.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\assembly\dl3\99ecec98\5910fe62_c166d001\System.Net.Http.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.ApplicationServices\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.ApplicationServices.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\assembly\dl3\9de122ff\b91b3e62_c166d001\Microsoft.Web.Infrastructure.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.IdentityModel\v4.0_4.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\assembly\dl3\fbfbd4bd\39818e5e_c166d001\EntityFramework.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\assembly\dl3\ffac86cd\891be662_c166d001\System.Net.Http.Formatting.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\assembly\dl3\8605756c\e96cbb63_c166d001\Antlr3.Runtime.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Web\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_64\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.DynamicData\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.DynamicData.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.Activities.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activities.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\assembly\dl3\36109d7b\e9612b63_c166d001\System.Web.Http.WebHost.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_64\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\assembly\dl3\4f57f544\09f8a262_c166d001\System.Web.WebPages.Razor.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\assembly\dl3\d158af50\99a16e62_c166d001\System.Web.Razor.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\assembly\dl3\ef6c4a66\99a51463_c166d001\System.Web.Http.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.WorkflowServices\v4.0_4.0.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\assembly\dl3\8e8f3977\09bbbb63_c166d001\WebGrease.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Extensions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\assembly\dl3\d77cc774\f9d0a262_c166d001\System.Web.WebPages.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\assembly\dl3\2a661060\ca8bb29e_0d87d001\TdCodeApp.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\assembly\dl3\35b296bd\c95ba262_c166d001\System.Web.WebPages.Deployment.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\assembly\dl3\f24b5800\b94f5963_c166d001\System.Web.Providers.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\assembly\dl3\fd882dc8\5910fe62_c166d001\System.Net.Http.WebRequest.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\assembly\dl3\35c5ca4c\69d4cf62_c166d001\Microsoft.Web.Mvc.FixedDisplayModes.dll" /out:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\App_global.asax.6rl89b0n.dll" /debug- /optimize+ /w:4 /nowarn:1659;1699;1701 /warnaserror- "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\App_global.asax.6rl89b0n.0.cs" "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\App_global.asax.6rl89b0n.1.cs"rnrnrnMicrosoft (R) Visual C# 2010 Compiler version 4.0.30319.524rnCopyright (C) Microsoft Corporation. All rights reserved.rnrnerror CS0016: Could not write to output file 'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ca8ed912\d7b1512d\App_global.asax.6rl89b0n.dll' -- '拒绝访问。 'rnrn rnrnrnrnrn--------------------------------------------------------------------------------rnVersion Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.2027 论坛

MVC4中 新增页面

09-10

MVC4 中rn新增页面 新增记录为 TableEntity的对象rn[code=csharp]rnpublic class TableEntityrn rn public string TableName get; set; rn public string TableType get; set; rn public List Cols get; set; rn rnpublic class Colmunrn rn public string ColumnName get; set; rn public string ColumnValue get; set; rn rn[/code]rnview 中rn[code=html]rn@using (Html.BeginForm()) rn @Html.ValidationSummary(true)rnrn rn TableEntityrnrn rn @Html.LabelFor(model => model.TableName)rn rn //这是TableName 的输入框rn @Html.EditorFor(model => model.TableName)rn @Html.ValidationMessageFor(model => model.TableName)rn rnrn rn @Html.LabelFor(model => model.TableType)rn rn rn @Html.EditorFor(model => model.TableType)//这是TableType 类型的输入框rn @Html.ValidationMessageFor(model => model.TableType)rn rnrn rn 1.这里是 Cols 的输入框,要显示为“ 列名输入textbox, 列的值输入textbox” 列名和列值为1对1 rn 请问这里应该怎么写?rn 2.如果这里 Cols 的列为动态添加的,用户点一下添加一列,这一列 能映射到model 中,这样提交后就可以直接在后台取到了。rnrn rnrn rn //这里点击后 执行controller下的程序rn rn rnrn[/code]rnrncontroller:rn[code=csharp]rn[HttpPost]rn public ActionResult Create(TableEntity table)rn rn tryrn rn // TODO: Add insert logic herern //这里可以接收到 view 中 动态生成列的集合 table.Colsrn return RedirectToAction("Index");rn rn catchrn rn return View();rn rn rn[/code]rn[img=https://img-bbs.csdn.net/upload/201309/10/1378799818_518970.jpg][/img] 论坛

百度编辑器Ueditor1.3.6 Net版本发布问题

03-30

最近在帮学校在做一个竞赛平台,因为要发布新闻,所以用到了百度编辑器,奈何学校的外网服务器最高只主支持到.NET3.5版本,所以只能使用百度编辑器Ueditor1.3.6(不是最新版,还是修改了它的后台源代码才行)。在利用IIS Express8.0测试时(我使用的是win7 64系统),它的文件上传功能是正常的。正常情况下,在上选择上传附件时,后台会返回一些文件夹的相对路径。如下图所示:rn[img=https://img-bbs.csdn.net/upload/201503/30/1427701996_798526.jpg][/img]rn返回的信息rn[img=https://img-bbs.csdn.net/upload/201503/30/1427702008_230558.jpg][/img]rn最后可以选择要上传到的文件夹rn[img=https://img-bbs.csdn.net/upload/201503/30/1427702015_31489.jpg][/img]rn后台文件结构为:rn[img=https://img-bbs.csdn.net/upload/201503/30/1427702161_646789.jpg][/img]rn它的图片上传和附件上传都要用到那个Uploader.cs文件里的内容。在使用IIS Express8.0测试时是没有问题的,但当发布后,要使用上传功能时,使用IIS服务器访问,问题就来了。rn首先它报告一个问题:说ashx文件不存在在:rn[img=https://img-bbs.csdn.net/upload/201503/30/1427702468_93291.jpg][/img]rn但事实上,那个文件是存在的:rn[img=https://img-bbs.csdn.net/upload/201503/30/1427702511_492965.jpg][/img]rn然后又是无法找到Uploader.cs文件,但在发布网站时,这个文件应该被编译成了dll文件里的一部分,rn[img=https://img-bbs.csdn.net/upload/201503/30/1427703009_528008.jpg][/img]rn而ashx文件里有一句要引用这个文件的语句:rn[img=https://img-bbs.csdn.net/upload/201503/30/1427703024_359837.jpg][/img]rn各位大神,这个问题怎么破呀???????? 论坛

关于MVC4页面权限,登录后自动跳转到之前受限页面

01-27

[code=csharp] public class MemberValidationAttribute : AuthorizeAttributern rn protected override bool AuthorizeCore(System.Web.HttpContextBase httpContext)rn rn var isAuthorized = false;rn if (!string.IsNullOrEmpty(HttpContext.Current.User.Identity.Name) && !string.IsNullOrEmpty(UserInfo.UserId))rn rn return isAuthorized = true;rn rn else if (!string.IsNullOrEmpty(HttpContext.Current.User.Identity.Name))rn rn if (string.IsNullOrEmpty(UserInfo.UserId))rn rn Regex r = new Regex("\\d+");rn var ms = r.Matches(HttpContext.Current.User.Identity.Name);rn if (ms.Count > 0)rn rn System.Data.DataTable dt = Extension.GetData(" select c.name as CustomerName ,c.HSCODE as CustomerHscode,c.CIQCODE as CustomerCiqcode, c.code CustomerCode,u.* from SYS_USER u left join sys_customer c on u.customerid = c.id and u.id ='" + ms.OfType().Last().ToString() + "'");rn if (dt.Rows.Count > 0)rn rn UserInfo.UserId = dt.Rows[0]["ID"] + "";rn UserInfo.UserName = dt.Rows[0]["NAME"] + "";rn UserInfo.IsLogin = true;rn UserInfo.CustomerId = !string.IsNullOrEmpty(dt.Rows[0]["CustomerId"] + "") ? Convert.ToInt32(dt.Rows[0]["CustomerId"]) : 0;rn UserInfo.RealName = dt.Rows[0]["RealName"] + "";rn UserInfo.Email = dt.Rows[0]["Email"] + "";rn UserInfo.Sex = !string.IsNullOrEmpty(dt.Rows[0]["Sex"] + "") ? Convert.ToInt32(dt.Rows[0]["Sex"]) : 0;rn UserInfo.Telephone = dt.Rows[0]["Telephone"] + "";rn UserInfo.Mobilephone = dt.Rows[0]["Mobilephone"] + "";rn UserInfo.Type = !string.IsNullOrEmpty(dt.Rows[0]["Type"] + "") ? Convert.ToInt32(dt.Rows[0]["Type"]) : 0;rn UserInfo.Enabled = !string.IsNullOrEmpty(dt.Rows[0]["Enabled"] + "") ? Convert.ToInt32(dt.Rows[0]["Enabled"]) : 0;rn UserInfo.Remark = dt.Rows[0]["Remark"] + "";rn UserInfo.POINTS = !string.IsNullOrEmpty(dt.Rows[0]["POINTS"] + "") ? Convert.ToInt32(dt.Rows[0]["POINTS"]) : 0;rn UserInfo.CustomerName = dt.Rows[0]["CustomerName"] + "";rn UserInfo.CustomerHscode = dt.Rows[0]["CustomerHscode"] + "";rn UserInfo.CustomerCiqcode = dt.Rows[0]["CustomerCiqcode"] + "";rn UserInfo.CustomerCode = dt.Rows[0]["CustomerCode"] + "";rn rn rn return isAuthorized = true;rn rn rn return isAuthorized;rn rn protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)rn rn rn if (string.IsNullOrEmpty(HttpContext.Current.User.Identity.Name))rn rn filterContext.Result = new RedirectResult("/Account/Login");rnrn //string path = filterContext.HttpContext.Request.Path;rn //filterContext.Result = new RedirectToRouteResult(rn // new RouteValueDictionary rn // "action", "Index" ,rn // "controller", "Home" ,rn // "ReturnUrl", pathrn // rn // );rn [/code]rn我在必须登录才能访问的方法前都加了[MemberValidation]特性 现在没有登录访问那些限制页面都能跳转到登录页面去 怎么登录后跳转到限制页面呢 论坛

没有更多推荐了,返回首页