此处将为大家介绍关于c#–System.Web.HttpException:不能在DropDownList中选择多个项目的详细内容,并且为您解答有关不能在memo.ole或超级链接对象(pic1)的相
此处将为大家介绍关于c# – System.Web.HttpException:不能在DropDownList中选择多个项目的详细内容,并且为您解答有关不能在memo.ole或超级链接对象(pic1)的相关问题,此外,我们还将为您介绍关于asp.net mvc下拉框Html.DropDownList 和DropDownListFor的常用方法、Asp.net web api 2 OWIN 管道 MessageHandlers 间歇性地获取这个“System.Net.HttpListenerException”、asp.net – Googlebot导致.NET System.Web.HttpException、asp.net – MVC DropDownListFor – NullReferenceException被usercode取消了的有用信息。
本文目录一览:- c# – System.Web.HttpException:不能在DropDownList中选择多个项目(不能在memo.ole或超级链接对象(pic1))
- asp.net mvc下拉框Html.DropDownList 和DropDownListFor的常用方法
- Asp.net web api 2 OWIN 管道 MessageHandlers 间歇性地获取这个“System.Net.HttpListenerException”
- asp.net – Googlebot导致.NET System.Web.HttpException
- asp.net – MVC DropDownListFor – NullReferenceException被usercode取消了
c# – System.Web.HttpException:不能在DropDownList中选择多个项目(不能在memo.ole或超级链接对象(pic1))
dropDownList.Items.FindByValue(myValue).Selected = true; // assume myValue is found at index 1 of dropDownList.Items
页面加载完成后,页面显示为:“System.Web.HttpException:DropDownList中不能选择多个项目”.
为什么我得到例外?我该怎么解决?
解决方法
我尝试通过事先清除列表选项来解决这个问题.
dropDownList.ClearSelection(); dropDownList.Items.FindByValue(myValue).Selected = true;
但这没有帮助.发生同样的例外
有什么帮助,另一种方式是设置选定的值:
dropDownList.Selectedindex = dropDownList.Items.IndexOf(dropDownList.Items.FindByValue(myValue));
现在的选择变化在整个列表中发生变化.
所以,不要使用dropDownList.Items [x] .Selected = true / false来更改DropDownList的选定值.而是使用dropDownList.Selectedindex = x;
asp.net mvc下拉框Html.DropDownList 和DropDownListFor的常用方法
一、非强类型:
Controller:
ViewData["AreId"] = from a in rp.GetArea()
select new SelectListItem {
Text=a.AreaName,
Value=a.AreaId.ToString()
};
View:
@Html.DropDownList("AreId")
还可以给其加上一个默认选项:@Html.DropDownList("AreId", "请选择");
二、强类型:
DropDownListFor常用的是两个参数的重载,第一参数是生成的select的名称,第二个参数是数据,用于将绑定数据源至DropDownListFor
Modle:
public class SettingsViewModel
{
Repository rp =new Repository();
public string ListName { get; set; }
public IEnumerable<SelectListItem> GetSelectList()
{
var selectList = rp.GetArea().Select(a => new SelectListItem {
Text=a.AreaName,
Value=a.AreaId.ToString()
});
return selectList;
}
}
Controller:
public ActionResult Index()
{
return View(new SettingsViewModel());
}
View:
@model Mvc3Applicationtest2.Models.SettingsViewModel
@Html.DropDownListFor(m=>m.ListName,Model.GetSelectList(),"请选择")
- ASP.NET MVC实现多选下拉框
- 详解ASP.NET MVC 下拉框的传值的两种方式
- ASP .NET 可编辑输入自动匹配的下拉框
- 详解ASP.NET MVC之下拉框绑定四种方式
- ASP.NET MVC下拉框联动实例解析
- ASP.NET中DropDownList下拉框列表控件绑定数据的4种方法
- ASP.NET实现级联下拉框效果实例讲解
- ASP.NET多彩下拉框开发实例
- asp.net中js+jquery添加下拉框值和后台获取示例
- asp.net 实现下拉框只读功能
- ASP.NET MVC下拉框中显示枚举项
Asp.net web api 2 OWIN 管道 MessageHandlers 间歇性地获取这个“System.Net.HttpListenerException”
如何解决Asp.net web api 2 OWIN 管道 MessageHandlers 间歇性地获取这个“System.Net.HttpListenerException”?
为此一直在挠头,但无济于事。 我有这个 Asp.net web api 项目,使用 OWIN 进行自托管。
一切看起来都很好,对我来说也很好,直到我安装了 New Relic
作为监视器,有时我可以看到这个“异常”记录在 New Relic 中。
有趣的是,这个异常似乎没有在我的应用程序中抛出(并且从未显示在应用程序的日志中),但它以某种方式被 New Relic 接收了。无论如何,我还是想知道根本原因和解决方案(如果有的话)。
整个堆栈跟踪
System.Net.Http.HttpRequestException: Error while copying content to a stream. ---> System.IO.IOException: ---> System.Net.HttpListenerException: The I/O operation has been aborted because of either a thread exit or an application request
at System.Net.HttpResponseStream.EndWrite(IAsyncResult asyncResult)
at Microsoft.Owin.Host.HttpListener.RequestProcessing.ExceptionFilterStream.EndWrite(IAsyncResult asyncResult)
--- End of inner exception stack trace ---
at Microsoft.Owin.Host.HttpListener.RequestProcessing.ExceptionFilterStream.EndWrite(IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar,Func`2 endFunction,Action`1 endAction,Task`1 promise,Boolean requiresSynchronization)
--- End of inner exception stack trace ---
at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Owin.HttpMessageHandlerAdapter.<SendResponseContentAsync>d__33.MoveNext()
老实说,我真的不知道问题出在哪里,但我怀疑 OWIN 管道可能是原因。
因此,我试图按照这个想法进行复制。
在 startup
中,我添加了这个非常标准的日志记录管道
config.MessageHandlers.Add(new LoggingMessageHandler())
实现看起来像这样
public class LoggingMessageHandler : DelegatingHandler
{
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)
{
var log = "Request:\n" + request.ToString();
log += "\nBody:\n" + FiltterLogMessage(await request.Content.ReadAsstringAsync());
Logger.Debug(log);
HttpResponseMessage response = await base.SendAsync(request,cancellationToken);
log = "Response:\n" + response.ToString();
log += "\nBody:\n" + FiltterLogMessage(await response.Content.ReadAsstringAsync());
Logger.Debug(log);
return response;
}
}
我有时可以通过以下方式进行复制: 1:使用像 JMeter
这样的 API 压力测试代理在短时间内(30 秒内 150 个)发送大量请求。然后,把这个 Thread.Sleep(5000)
放在像这样的异步方法之前
Thread.Sleep(5000);
HttpResponseMessage response = await base.SendAsync(request,cancellationToken);
当然我需要关注新的遗物,因为它永远不会被扔到我的应用程序中。如果幸运的话,我可以在 New Relic 中记录一些异常。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
asp.net – Googlebot导致.NET System.Web.HttpException
由于这些变化,ELMAH从传统的asp页面报告错误,实际上没有细节(和状态代码404):
System.Web.HttpException (0x80004005) at System.Web.CachedpathData.ValidatePath(String physicalPath) at System.Web.HttpApplication.PipelinestepManager.ValidateHelper(HttpContext context)
但是当我自己请求页面时,不会发生错误.所有出现在ELMAH中的错误都是由Googlebot抓取工具(用户代理字符串)引起的.
.NET如何为传统的asp页面挑选错误?这与集成管道有关吗?
任何想法,为什么错误只发生在Google抓取页面或如何获得更多的细节来找到潜在的错误?
解决方法
<httpRuntime relaxedUrlToFileSystemMapping="true" />
此disables the default check确保所请求的URL符合Windows路径规则.
要重现问题,请将(URL转义的空格)添加到URL的末尾,例如http://example.org/.当搜索抓取工具遇到带有空格的错误类型的链接时,这是很常见的. < a href =“http://example.org/”>示例< / a> ;. HttpContext.Request.Url属性似乎修剪了尾随空间,这就是为什么像ELMAH这样的日志记录工具不会揭示实际的问题.
asp.net – MVC DropDownListFor – NullReferenceException被usercode取消了
How to write a simple Html.DropDownListFor()?我正在尝试BaraT的解决方案,但面临NullReferenceException的错误.以下是我的代码.
<%: Html.DropDownListFor(model => model.CreditCardType,new SelectList( new List<Object>{ new { value = 0,text="VISA"},new { value = 1,text="Master"},new { value = 2,text="Debit"}},"value","text",Model.CreditCardType) )%>
ErrorDetail:未将对象引用设置为对象的实例.
谁能帮帮我吗?我可能会犯小错误但无法修复它.
解决方法
model.CreditCardType,new SelectList( new List{ new { value = 0,"VISA") )%>
今天关于c# – System.Web.HttpException:不能在DropDownList中选择多个项目和不能在memo.ole或超级链接对象(pic1)的介绍到此结束,谢谢您的阅读,有关asp.net mvc下拉框Html.DropDownList 和DropDownListFor的常用方法、Asp.net web api 2 OWIN 管道 MessageHandlers 间歇性地获取这个“System.Net.HttpListenerException”、asp.net – Googlebot导致.NET System.Web.HttpException、asp.net – MVC DropDownListFor – NullReferenceException被usercode取消了等更多相关知识的信息可以在本站进行查询。
本文标签: