Tag: asp.net

HTTP错误414.请求URL太长。 asp.net

我收到错误“HTTP错误414.请求URL太长。” 从以下文章中,我了解到这是由于查询字符串非常长: Solution for Query String Too Long Error 在web.config中,我有maxQueryStringLength=”2097151″ 。 这是最大值吗? 为了解决这个问题,我应该在web.config中设置maxUrl吗? 如果是这样,支持的最大值是多少? 我该怎么做才能解决这个错误?

如何从xml文件中读取单个节点值

嗨,我想从xml获取值,但它显示节点null。 这是我的xml文件。 MailingGUID 0aa2b2e3-7afa-4002-ab2f-9eb4cbe33ae7 OrderRef 52186 我想得到“MailingGUID”的价值。 这是我尝试过的代码: private void readXML() { XmlDocument xml = new XmlDocument(); // You’ll need to put the correct path to your xml file here xml.Load(Server.MapPath(“~/XmlFile11.xml”)); // Select a specific node XmlNode node = xml.SelectSingleNode(“result/data/value”); // Get its value string name = node.InnerText; } 请告诉我如何获得MailingGUID值。 谢谢

AjaxfileUpload错误

我正在尝试实现一个简单的ajaxtoolkit文件上载控件,每次单击“上传”,我得到的都是错误。 我尝试在“AjaxFileUpload1_UploadComplete”函数中放置断点但它甚至不会被解雇..(可能是因为上传尚未完成?)我该怎么做才能使它工作? 这是错误: 这是我的aspx: 这是背后的function: protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) { string id = “038191904”; Directory.CreateDirectory(Server.MapPath(“~/App_Data/” + id + “/scanned_docs/”)); string filePath = “~/Member_Data/” + id + “/images/”; string path = filePath + e.FileName; AjaxFileUpload1.SaveAs(Server.MapPath(filePath) + e.FileName); //db1.insert_pic_slide(id, path); }

从Gridview单元格中获取价值

我正在尝试从GridView获取一个int值。 这是我的gridview的截图。 这是Gridview的asp代码 我创建了一个RowCommand方法,当我按下GridView上的Remove按钮时,它假设给我第二列的int值。 因此,例如,如果我按下最后一个删除按钮,它将给我一个int值为5。 这是我的方法的代码隐藏 protected void grdOrder_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == “Remove”) { int bigStore = Convert.ToInt32(grdOrder.SelectedRow.Cells[2].Text); clsStockCollection AnId = new clsStockCollection(); clsStock TheOrder = new clsStock(); TheOrder.OrderId = bigStore; AnId.DeleteOrder(TheOrder); DataCall(); } } 当我运行此代码时,我收到此错误。 你调用的对象是空的。 我不明白我需要如何或为什么需要引用一个对象,例如:Object As New Object。 为什么我需要这样做? 以下是完整类的代码隐藏:pastebin.com/yzLR7s2w 提前谢谢

尝试调试ASP.NET网站时Visual Studio 2013 sp1挂起?

最近,在尝试调试/跟踪ASP.NET网站时,Visual Studio 2013再次开始挂起。 该网站是使用WebMatrix 3创建的,但我不认为这是相关的。 VS2013打开网站解决方案。 加载需要很长时间。 一旦它加载并运行项目,它就会到达我的第一个断点,然后IDE窗口会在标题栏中快速显示“(没有响应)”,IDE现在已挂起。 很久以前发生在我身上,根本原因是需要设置“使用64位IIS”选项,如此SOpost所示: 每次运行测试解决方案时,Visual Studio 2013都会崩溃并重新启动 但我三重检查,我确实检查了64位选项。 我该怎么做才能解决这个问题?

如何在后面的代码中访问html控件

我正在尝试按照这个示例来validation凭据。 但是,它使用asp:controls作为登录表单。 如果我使用html控件,那么可以应用CSS样式,例如 Login Sign in to your account. Forgot your password? 如何在代码后面的代码中访问用户名和密码? protected void LoginButton_Click(object sender, EventArgs e) { // Validate the user against the Membership framework user store if (Membership.ValidateUser(UserName.Text, Password.Text)) { // Log the user into the site FormsAuthentication.RedirectFromLoginPage(UserName.Text, RememberMe.Checked); } // If we reach here, the user’s credentials were invalid InvalidCredentialsMessage.Visible […]

设置“选择”HTML控件的选定值

如何使用ASP.NET和C#从代码隐藏文件中设置Select HTML控件的选定值?

检查是否可以访问URL – 帮助优化类

net 4和c#。 如果Uri(字符串)返回HTTP状态代码200,我需要一个能够返回Bool值的Class。 目前我有这个代码(它使用try来查看是否可以连接到Uri),但我希望用“HttpStatusCode.OK”实现。 你知道更好的方法吗? 谢谢。 public static bool IsReachableUri(string uriInput) { // Variable to Return bool testStatus; // Create a request for the URL. WebRequest request = WebRequest.Create(uriInput); request.Timeout = 15000; // 15 Sec WebResponse response; try { response = request.GetResponse(); testStatus = true; // Uri does exist response.Close(); } catch (Exception) { testStatus […]

如何优雅地摆脱AbandonedMutexException?

我使用以下代码来同步多个正在运行的进程之间对共享资源的互斥访问。 互斥锁是这样创建的: Mutex mtx = new Mutex(false, “MyNamedMutexName”); 然后我用这个方法进入互斥部分: public bool enterMutuallyExclusiveSection() { //RETURN: ‘true’ if entered OK, // can continue with mutually exclusive section bool bRes; try { bRes = mtx.WaitOne(); } catch (AbandonedMutexException) { //Abandoned mutex, how to handle it? //bRes = ? } catch { //Some other error bRes = false; } […]

如何在response.redirect上使用Target = _blank?

我不一定要使用response.redirect,但这就是我所拥有的。 我想在新窗口中打开所选链接。 我怎么做? context.Response.Redirect(ConfigurationManager.AppSettings[“URL”] + ext );