小编Eri*_*Cal的帖子

带参数的RedirectToAction

我有一个我从锚中调用的动作,Site/Controller/Action/ID其中ID是一个int.

稍后我需要从Controller重定向到同一个Action.

有一个聪明的方法来做到这一点?目前我正在ID使用tempdata,但是当你回到f5后再次刷新页面时,tempdata就会消失,页面崩溃了.

c# asp.net-mvc controller redirecttoaction

555
推荐指数
13
解决办法
72万
查看次数

Asp.Net MVC如何获取生成PDF的视图

我想在控制器上调用一个动作.让控制器从模型中获取数据.然后该视图将运行并生成PDF.我找到的唯一例子是Lou的一篇文章http://whereslou.com/2009/04/12/returning-pdfs-from-an-aspnet-mvc-action.他的代码非常优雅.该视图使用ITextSharp生成PDF.唯一的缺点是他的例子使用了Spark View引擎.有没有办法用标准的Microsoft视图引擎做类似的事情?

pdf asp.net-mvc

72
推荐指数
5
解决办法
8万
查看次数

asp.net c#从http重定向到https

因此,在我的代码中,我想检测我的登录页面是否被称为http,并将其重定向到https.

我知道有一些非代码方法来修饰这只猫,但是由于令人沮丧的技术原因,我已经支持在代码中进行操作.

            if (!Request.IsSecureConnection)
            {
                string redirectUrl = Request.Url.ToString().Replace("http:", "https:");
                Response.Redirect(redirectUrl);
            }
Run Code Online (Sandbox Code Playgroud)

所以我把它放在我的Page_Load(...),确保我的调试器使用真正的IIS,而不是VS2008s IIS,并点击调试.

在调试器中,跳转,点击Response.Redirect(" https://localhost/StudentPortal3G/AccessControl/AdLogin.aspx "),点击f5.

获取"Internet Explorere无法显示网页,网址是HTTP,而不是HTTPS.没有收到信息错误...同样的事情发生在调试器中没有运行.

那我错过了什么?它似乎不是火箭科学,我在许多博客上看到了类似的代码......

我究竟做错了什么?我认为它必须是一个完全明显的新秀错误,但我没有看到它.

asp.net https http

50
推荐指数
4
解决办法
8万
查看次数

MSBuild MSBuildCommunityTasks任务时间

我有一个MSBuild项目,我希望将当前日期添加到我正在创建的zip文件中.

我正在使用MSBuildCommunityTasks.

<!-- Import the CommunityTasks Helpper -->
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
Run Code Online (Sandbox Code Playgroud)

在网站http://msbuildtasks.tigris.org/上我可以看到一个叫做时间的任务.我还没能找到关于如何使用Time的文档.

msbuild msbuild-task msbuildcommunitytasks

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

如何在Visual Studio 2010 AddIn中写入输出窗口?

我正在编写一个简单的Visual Studio 2010加载项,以便在工作中执行常见的复制工作(从libs sln获取dll).

我希望将复制的进度写入输出窗口.

我试过Trace.WriteLine(...)要做到这一点,但是当我在调试器中运行加载项时却没有.我还没有尝试过任何其他方式.

我在Visual Studio 2008中找到了一些这样做的示例,但是无法引用所需的库.

谁能指点我如何写入输出窗口?我的谷歌搜索技能让我失望.

add-in visual-studio-addins visual-studio-2010

11
推荐指数
2
解决办法
4509
查看次数

获取JQGrid格式化程序:'showlink'在MVC中工作

我的列正在显示,它正在为我的链接生成一个锚点.唯一的问题是网址很糟糕的MVC

这是colModel:

                colModel: [

                  { name: 'RegName',  index: 'RegName', label: 'Region Name',width:90, align: 'center' },
                  { name: 'AccessNbr', index: 'AccessNbr', label: 'Access Number',width:80, align: 'center', formatter: 'showlink', formatoptions: {baseLinkUrl: '', showAction: 'GetBoxesForPorId', addParam: ''}  },
                  { name: 'TransmitedDt', index: 'TransmitedDt', label: 'TransmitedDt',  align: 'center' },
                  { name: 'BoxCount', index: 'BoxCount', label: 'Box Count', align: 'center' },
                  { name: 'PorId',  hidden:false ,index: 'PorId', label: 'Por ID', key:true ,formatter:'link', formatoptions: {target:'_new'}  }                           
                ]
Run Code Online (Sandbox Code Playgroud)

这是它构建的url: http:// localhost:4618/Por/GetBoxesForPorId?id = 16

我想要它构建的URL是: http:// localhost:4618/Por/GetBoxesForPorId/16

asp.net-mvc jquery jqgrid

7
推荐指数
1
解决办法
1万
查看次数

检测异常是否为损坏状态异常

我有一些调用Rotativa的代码,它调用了wkhtml2pdf.我怀疑从行为中我看到wkhtml2pdf.exe导致损坏的状态异常(CSE)被抛出.我想抓住并记录CSE,如果抛出,我可以追踪它发生的位置.

当我在调试器中让应用程序一夜之间运行时,当我回来时VS已关闭.有时它已重新启动,有时不会.怀疑内存腐败我开始研究并偶然发现CSE处理.

我正在做这样的事情:

[HandleProcessCorruptedStateExceptions]
void DoStuff()
{
     try
     {
          DOThatThingThatMakesTheDebuggerHaltAndShutDown();
     }
     catch(Exception ex)
     {
            //how do I detect that it's a CSE in here, so I can log it especially blatantly
     }
}
Run Code Online (Sandbox Code Playgroud)

有没有办法检测例外是否是General Catch中的CSE?

我看到一个kludge,他们有2个一般的例外条款.内部的不处理CSE并设置标志.如果在没有旗帜的情况下调用外部,那么它就是CSE,但我希望能有更清洁的东西.我想做的是记录这个糟糕的状态,然后将它传递给应用程序以正常冒泡.

当我查看事件日志中导致VS2013失败的错误时,我得到了这个:

应用程序:devenv.exe Framework版本:v4.0.30319描述:由于未处理的异常,进程已终止.异常信息:异常代码0000005,异常地址4DA44C1F堆栈:在Microsoft.VisualStudio.Debugger.Clr.NativeDkmClrModuleInstance.ProcF4BC786AEBAC294EE9C4C0BB1B0F56A7(IntPtr的,IntPtr的为ByRef)在Microsoft.VisualStudio.Debugger.Clr.DkmClrModuleInstance.GetMetaDataImport()在Microsoft.IntelliTrace.Concord Microsoft.IntelliTrace.Concord.Integration.CpdeNotifyPointServiceAdapter.InstallBreakpoint中的.MetadataHelper..ctor(Microsoft.VisualStudio.Debugger.Clr.DkmClrModuleInstance)(Microsoft.VisualStudio.Debugger.Clr.DkmClrModuleInstance,Microsoft.VisualStudio.Debugger.Interop.Internal.NP_INSTALL_REQUEST )
在Microsoft.IntelliTrace.Concord.Integration.CpdeNotifyPointServiceAdapter.BindToModule(Microsoft.VisualStudio.Debugger.Clr.DkmClrModuleInstance)在Microsoft.IntelliTrace.Concord.IntelliTraceProcessState.AlertModuleLoad(Microsoft.VisualStudio.Debugger.DkmModuleInstance)在Microsoft.IntelliTrace.Concord. NotifyPoints.NotifyPointManager.OnModuleInstanceLoad(Microsoft.VisualStudio.Deb Microsoft.VisualStudio.Debugger.EntryPoint.IDkmModuleInstanceLoadNotification_OnModuleInstanceLoad(IntPtr,IntPtr,IntPtr,IntPtr)中的ugger.DkmModuleInstance,Microsoft.VisualStudio.Debugger.DkmWorkList,Microsoft.VisualStudio.Debugger.DkmEventDescriptorS)

接下来是这样的:

错误应用程序名称:devenv.exe,版本:12.0.30501.0,时间戳:0x5361f453错误模块名称:vsdebugeng.impl.DLL,版本:12.0.30501.0,时间戳:0x5361f482异常代码:0xc0000005错误偏移量:0x00094c1f错误进程ID: 0x1c9c错误应用程序启动时间:0x01cfe7cc0cf50465错误应用程序路径:C:\ Program Files(x86)\ Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe错误模块路径:C:\ Program Files(x86)\ Microsoft Visual Studio 12.0\Common7\Packages\Debugger\vsdebugeng.impl.DLL报告ID:097b17c6-5438-11e4-8409-001f2904053c

c# exception corrupted-state-exception visual-studio-2013

7
推荐指数
1
解决办法
1057
查看次数

AppDomain.CreateInstance和Activator.CreateInstance有什么区别?

我想问一个问题来实现AppDomain和Activator之间的区别,我通过appdomain.CreateInstance加载了我的dll.但我意识到创建实例的方法更多.因此,何时或何地选择此方法?例1:

    // Use the file name to load the assembly into the current
    // application domain.
    Assembly a = Assembly.Load("example");
    // Get the type to use.
    Type myType = a.GetType("Example");
    // Get the method to call.
    MethodInfo myMethod = myType.GetMethod("MethodA");
    // Create an instance.
    object obj = Activator.CreateInstance(myType);
    // Execute the method.
    myMethod.Invoke(obj, null);
Run Code Online (Sandbox Code Playgroud)

例2:

public WsdlClassParser CreateWsdlClassParser()
{
    this.CreateAppDomain(null);

    string AssemblyPath = Assembly.GetExecutingAssembly().Location; 
    WsdlClassParser parser = null;
    try
    {                
        parser = (WsdlClassParser) this.LocalAppDomain.CreateInstanceFrom(AssemblyPath,
                                          typeof(Westwind.WebServices.WsdlClassParser).FullName).Unwrap() ;                
    }
    catch (Exception ex) …
Run Code Online (Sandbox Code Playgroud)

.net c# appdomain activator

6
推荐指数
1
解决办法
3821
查看次数

Angular在ASP.NET MVC之上,显示错误

我们在现有的asp.net c#MVC应用程序上放置一个有角度的前端.在我们的服务器代码中,我们可以使用自定义异常来返回商业规则错误.

有没有最好的做法或最简单的方法来处理mvc控制器或webApi控制器上的异常(实际上是从商务层跳出来)并将其转换为角度并在"用户错误"弹出窗口中显示它?人们如何解决这个问题?

c# asp.net-mvc angularjs

5
推荐指数
1
解决办法
4989
查看次数

尝试计算RDLC中列中非零行的平均值

有没有什么办法caculate非零的平均行仅适用于微软报表查看器的RDLC数据在表中的列?

即0 0 0 5 5 = 5而不是2

我尝试使用Count(fields.n.value> 0)来获取非零行的计数,但它返回了所有行的计数.

谢谢!

Eric-

reportviewer2008 reportviewer rdlc

4
推荐指数
1
解决办法
3194
查看次数