Tag: asp.net

在Web API中使用ExceptionFilterAttribute

我试图在创建的Web API中实现error handling,需要以JSON格式返回exception详细信息。 我创建了BALExceptionFilterAttribute之类的 public class BALExceptionFilterAttribute : ExceptionFilterAttribute { public override void OnException(HttpActionExecutedContext actionExecutedContext) { base.OnException(actionExecutedContext); actionExecutedContext.Response = actionExecutedContext.Request.CreateResponse(HttpStatusCode.BadRequest, new { error = actionExecutedContext.Exception.Message }); } } 并在Gloal.asax.cs中注册了它们 GlobalConfiguration.Configuration.Filters.Add(new BALExceptionFilterAttribute()); 在我的控制器中,我想抛出exception [HttpGet] [BALExceptionFilter] public HttpResponseMessage Getdetails(string ROOM, DateTime DOB_GT) { if (string.IsNullOrEmpty(ROOM) { return Request.CreateResponse(new { error = “Input paramete cannot be Empty or […]

如何删除Access Db的临时ldb文件

我有一个ASP.NET项目。 我正在连接到数据库,然后关闭并处理连接对象。 但是当任何人进入我的网站时,MS Access会创建一个临时的dbname.ldb。 当我想从我的服务器下载我的原始mdb文件时,它将不允许我访问mdb文件。 如果服务器中有ldb文件,我什么也做不了。 它锁定mdb文件,我无法移动它。 所以有什么问题? 我打开连接并关闭它。 那么为什么这个ldb文件在连接关闭后不会自行删除。

如何使用基于单元格值的颜色设置Asp.net GridView单元格样式

我有一个Gridview ,它有一个名为student_Class的列。 网格视图上有大约80个Class。 我使用GroupBy查询对此类进行了分组。 现在我想用不同的颜色设计这个不同的类。 这怎么可能? 在RowDataBound上编写所有类并给出颜色并不容易。 还有别的办法吗? 码: groups = (ArrayList)Session[“selectedclass”]; SELECT id,name,student_Class FROM student where student_Class='”+groups[0].ToString().Trim()+”‘ group by student_Class. 提供数据 id name student_class 1 aa A 2 bb A 3 cc A 4 dd B 5 ee B 6 as B 7 ss B 8 AZZ D 值A的学生class需要相同的颜色(对于单元格), B需要其他颜色。等。

Linq VAR和Typed对象

我想要一个代码示例。 目前我在c#和asp.net 4 ef4中使用linq var querySlotOrder = from slot in context.CmsSlots where slot.SlotId == myCurrentSlotId select slot; if (querySlotOrder.SlotOrder == myNewSlotOrder) e.Cancel = true; 此linq查询仅返回记录。 使用VAR我无法获取Typed对象,我无法访问其属性SlotOrder。 如何更改查询? 谢谢你的帮助 有用的资源主题: http://msdn.microsoft.com/en-us/library/bb384065.aspx http://msdn.microsoft.com/en-us/library/bb397947.aspx http://msdn.microsoft.com/en-us/library/bb397678.aspx

如何将ASP.NET MVC应用程序读取权限授予注册表项?

我已经阅读了有关如何实现这一目标的其他post,但无济于事。 当我将我的应用程序部署到服务器(2008)时,我在运行时收到以下exception: Access to the registry key ‘HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\Servers’ is denied. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.UnauthorizedAccessException: Access to the registry key ‘HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\Servers’ is denied. ASP.NET is not […]

SQL Server到Entity Framework的数据类型映射

我需要知道EF的等效SQL Server数据类型。 我发现了两个类似的在线参考,但它们的定义似乎不一致。 如果我使用entity framework,我应该参考哪个参考? 1) ADO.NET中的数据类型映射 http://msdn.microsoft.com/en-us/library/cc716729%28v=vs.110%29.aspx 2) .NET Framework中的SQL Server数据类型 http://msdn.microsoft.com/en-us/library/ms131092.aspx

Microsoft JScript运行时错误:’Sys.Extended.UI’为null或不是对象

我的页面有问题。 当它打开时,它会显示以下错误消息: Microsoft JScript运行时错误:’Sys.Extended.UI’为null或不是对象 并显示错误 $create(Sys.Extended.UI.ModalPopupBehavior, {“BackgroundCssClass”:”modalBackground1″,”DropShadow”:true,”PopupControlID”:”ctl00_ContentPlaceHolder1_panelPopupAddDefaultAddress”,”PopupDragHandleControlID”:”ctl00_ContentPlaceHolder1_panelPopupAddDefaultAddressDragHandle”,”dynamicServicePath”:”/SJM.Framework.Website/Order/ActiveOrders.aspx”,”id”:”ctl00_ContentPlaceHolder1_modalPopupAddDefaultAddress”}, null, null, $get(“ctl00_ContentPlaceHolder1_hiddenTargetControlForModalPopup”)); 任何人都可以告诉我我的问题是什么。 我试过了,但我还没找到。

ASP.net页面中的“System.Threading.ThreadAbortException”

我的ASP.net页面中有以下代码: Response.StatusCode = 404 Response.Write(strResult) Response.End() 上面的代码抛出“类型’System.Threading.ThreadAbortException’的exception发生并被捕获。” 谁能告诉我原因? 我能解决这个问题吗? 谢谢

服务器标签格式不正确

我在GridView上有以下图像按钮,我想通过传递参数调用OnClientClick来调用javascript方法。 我收到Server Tag没有很好的错误。 我尝试将双引号更改为单引号等,仍然是同一个问题。 OnClientClick=”return ConfirmOnDelete(”);” <asp:ImageButton ID="imgDelete" CommandName="Delete" ImageUrl="~/images/fbclose.png" AlternateText="Delete" runat="server" OnClientClick="return ConfirmOnDelete('’);”/>

代码Behing更新web.config映射问题

我从后面的代码我需要更新我的web.config。 这在以前从来就不是问题,但是我最近收到了一个错误。 错误说“无法映射路径’/’。” 注释掉的线条是我尝试的不同变化。 //Configuration myWebConfig = WebConfigurationManager.OpenWebConfiguration(Server.MapPath(“~”)); //Configuration myWebConfig = WebConfigurationManager.OpenWebConfiguration(“~”); //Configuration myWebConfig = WebConfigurationManager.OpenWebConfiguration(null); Configuration myWebConfig = WebConfigurationManager.OpenWebConfiguration(“.”); // update pages theme RoleManagerSection section = (RoleManagerSection)myWebConfig.GetSection(“system.web/roleManager”); section.DefaultProvider = “SqlRoleManager”; section.Providers.Clear(); ProviderSettings providerSettings = new ProviderSettings(); providerSettings.Name = “SqlRoleManager”; providerSettings.Type = “System.Web.Security.SqlRoleProvider”; providerSettings.Parameters.Clear(); providerSettings.Parameters.Add(“connectionStringName”, “SimpleTickConnection”); providerSettings.Parameters.Add(“applicationName”, “TheaterSales”); section.Providers.Add(providerSettings); myWebConfig.Save();