asp.net-4.0

HttpWebRequest redirect with cookies

好久不见. 提交于 2019-12-11 03:50:57
问题 I know a lot of questions have been asked about HttpWebRequest. However, I can't find any answer for the problem I'm having. I need to mimic the way browsers redirect URLs. My code works fine but not for the URL below: My code: sURL = "http://ad2.adfarm1.adition.com/redi*lid=689397953768/sid=404178/kid=253598/bid=847344/c=33349/keyword=/sr=0/clickurl=&ClickTarget=_blank&"; CookieContainer oCookies = new CookieContainer(); HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create

How do I return an HTTP 400 - Bad Request error from a web form request?

拈花ヽ惹草 提交于 2019-12-11 03:27:26
问题 The subject pretty much says it all. I have an EstateReport web form that must be called with an EstateId request parameter. I want to return an appropriate HTTP error is this parameter us not present. How do I return an HTTP error 400 as my response? On a tangent, should I return an error if the required parameter isn't present, which I feel is more correct, or redirect to the search page for the report, which is more user friendly? 回答1: So from what I understand the form requires a

Why do I get to the endOfStream in a webrequest, if it is a persistent (keepalive) connection?

自作多情 提交于 2019-12-11 03:08:02
问题 I have a webrequest that createst a persistent (keepalive) connection to the server, e.g.: webRequest.ContentType = "application/x-www-form-urlencoded"; // Set the ContentLength property of the WebRequest. webRequest.ContentLength = byteArray.Length; webRequest.Timeout = Timeout.Infinite; webRequest.KeepAlive = true; webRequest.ReadWriteTimeout = Timeout.Infinite; //[System.Threading.Timeout]::Infinite webRequest.UserAgent = "www.socialblazeapp.com"; Stream dataStream = webRequest

Security of cached data in .NET

元气小坏坏 提交于 2019-12-11 02:45:54
问题 I cached one DataTable fetched from SQL Server 2005 through C# ASP .NET 4.0 Web App [around 50000 row 32 columns].. Cache by mean is on Client-Side . I want to know whether the DataTable is secure Or Insecure in the Cache ? If insecure than how to get that Data directly from cache and be viewed [not by my Web App as a non developer] how to secure the Data. 回答1: The data is as secure as the server and the web application are. If someone has physical access to the box (or through RDP), they can

How to precompile ASP.NET 4.0 to a Single DLL with VS 2010

杀马特。学长 韩版系。学妹 提交于 2019-12-11 02:37:46
问题 I recently upgraded from VS 2003 where I was working on a ASP.NET 2.0 website to VS 2010 where I have migrated to ASP.NET 4.0. So far it has been a big headache to get my site compiling with the new version. One problem was that my aspx.cs pages could not find the shared code libraries in my project. I solved this by moving my shared code to the App_Code folder (if there's a different/better way to do it please let me know). Another issue that I am finding confusing is with pre-compilation.

Make URL in ASP.Net user-friendly

*爱你&永不变心* 提交于 2019-12-10 23:38:03
问题 I'm trying to develop my first site in ASP.Net using Web Forms. I have a form with some controls and a TextBox control. While now I use GET request. When user submits a form his browser expects to get long URL, something like http://mysite.com/search.aspx?__VIEWSTATE=%2FwEPDwUJNTE2NjY5jMY4D2QWAgICD2QWAgIDDW8wAh4EVGV4dAUBMWRkZKthQ0zeIP5by49qIHwSuW6nOj8iLTdoCUzpH369xyg8&__EVENTVALIDATION=%2FwEWAwLnrcHhBQLs0bLrBgKM54rGBjGtX5fJOylLy4qRbt6DqPxO%2FnfcMOkHJBRFqZTZdsBD&TextBox1=sfs&Button1=Button if

getElementById in separate js file doesn't find ASP.net control

被刻印的时光 ゝ 提交于 2019-12-10 21:42:11
问题 When I have this in the page markup it works fine: <script type="text/javascript"> function bought1() { var s = '<%= Button2.ClientID %>'; var v = document.getElementById(s); v.click(); } </script> But when I have the same thing in a separate file, even though the function is executed - the value of v remains null . I tried with a simple div and it did find the div . Why doesn't it find the ASP.net Button? EDIT I even added ClientIDMode="Static" to the Button. No change. 回答1: <%= Button2

Converting anonymous type to DataTable

▼魔方 西西 提交于 2019-12-10 21:14:07
问题 What is the fastest way to convert anonymous type to DataTable? Update: I want to get and populate DataTable from anonymous type. If reflection is neccesary, how can I to do it using reflection? 回答1: Found here: var result = from p in dataSource group p by p.City into cities select new { Property1 = cities.Key, Property 2= cities.Average(p => p.Age) }; dt.Columns.Add("Property1"); dt.Columns.Add("Property2"); foreach (var item in result) { dt.Rows.Add(item.Property1,item.Property2); } See

Page.GetRoutUrl in a static method

血红的双手。 提交于 2019-12-10 18:58:46
问题 Some background on what I'm doing I usually like to have my pages return the url needed to access it. So i will normally have a method like so public partial class ProductDetails : Page { public static string GetUrl(Guid productId) { return "fully qualified url"; } } on my other pages/controls that need to access this page i'll simply set the link as hl.NavigateUrl = ProductDetails.GetUrl(id); I'm toying around with the new UrlRouting stuff in 4.0 and ran into something I'm not sure will work

ASP.NET special characters in URL (colon) not working even with requestPathInvalidCharacters=“”

人走茶凉 提交于 2019-12-10 17:55:34
问题 I need to pass a colon within an URL in ASP.NET, like "http://mywebapp.com/Portal:Main/". Wikipedia does this a lot, and colons are valid URL characters according to the RFC. I've found this SO question and read through this blog post which covers the invalid characters filter in ASP.NET. Using VS2010 Ultimate and trying with a new ASP.NET WebForms and a new ASP.NET MVC 2 project I always added this to my web.config: <httpRuntime requestPathInvalidCharacters="" /> as well as this <httpRuntime