ASP.NET

ASP.NET

Response for REST method was truncated because default MaxItemsInObjectGraph was not big enough.

We have a REST service with attributes [WebGet(UriTemplate ="...", BodyStyle =WebMessageBodyStyle.Bare, ResponseFormat =WebMessageFormat.Xml)]Norm... it worked fine. But for particular data it has a huge response that was truncated. The size returned in a few attempts in IE browser was 2196456, in Chrome slightly different 2195397.After a search in google I found http://forums.asp.net/post/... that has a number of suggestions. For WCF service that will transfer large amount of data in ......

Missing error handling in Streaming-AJAX-Proxy Log

We are using AjaxProxy(FROM http://www.codeproject.com/... on our web site, but started to notice errors accessing log.txt file. I found that the file is created by Log class and doesn't have ability to switch it off and error handling. I've added reading file name from configuration and try/catch block public static class Log { private static StreamWriter logStream; private static object lockObject = new object (); public static void WriteLine(string msg) { string logFileName ......

Adding Async=true to the page- no side effects noticed.

Recently I needed to implement PageAsyncTask in .Net 4 web forms application.According to http://msdn.microsoft.com/e... PageAsyncTask object must be registered to the page through the RegisterAsyncTask method. The page itself does not have to be processed asynchronously to execute asynchronous tasks. You can set the Async attribute to either true (as shown in the following code example) or false on the page directive and the asynchronous tasks will still ......

Configuration setting of HttpWebRequest.Timeout value

I wanted to set in configuration on client HttpWebRequest.Timeout.I was surprised, that MS doesn’t provide it as a part of .Net configuration.(Answer in http://forums.silverlight.n... thread: “Unfortunately specifying the timeout is not supported in current version. We may support it in the future release.”) I added it to appSettings section of app.config and read it in the method of My HttpWebRequestHelper class //The Method property can be set to any of the HTTP 1.1 protocol verbs: ......

Log JavaScript errors to the server.

Some time ago I found debugging - Automatic feedback on JavaScript error - Stack Overflow. and the discussion has links to Logging JavaScript Errors To ASP.NET(Unfortunately the link to download in the post is broken).and custom control to help log JavaScript errors by sending error information to the server -thecodepage.com/post/JavaS... downloaded solution from JSErrorNotifier.zip. When I wanted to include dll into my solution dependencies, I decided to rename WebControls.DLL ......

Select tool to minimize JavaScript and CSS size

There are multiple ways and techniques how to combine and minify JS and CSS files.The good number of links can be found in http://stackoverflow.com/qu... and in http://www.hanselman.com/bl... There are 2 major approaches- do it during build or at run-time.In our application there are multiple user-controls, each of them required different JS or CSS files, and ......

Dump an arbitrary object To Html String

For debugging purposes me and my collegue wanted to dump details of the arbitrary object, and created function that uses LINQPad Dump functionality (thanks to http://stackoverflow.com/a/... and original http://linqpad.uservoice.co... discussion) public static string DumpToHtmlString<T>(this T objectToSerialize) { string strHTML = ""; try { var writer = LINQPad.Util.CreateXhtmlWri... ......

Translate jQuery UI Datepicker format to .Net Date format

I needed to use the same date format in client jQuery UI Datepicker and server ASP.NET code. The actual format can be different for different localization cultures.I decided to translate Datepicker format to .Net Date format similar as it was asked to do opposite operation in http://stackoverflow.com/qu... Note that replace command need to replace whole words and order of calls is importantFunction that does ......

CodePlex downloads without strong name for an assembly

I wanted to use http://cache.codeplex.com/ in my solution, but it caused compile errorAssembly generation failed -- Referenced assembly does not have a strong nameREASON: When you compile an assembly with a strong name, any referenced assemblies must also have strong name.I could sign Cache project using Visual Studio or using commands as described in “Tip related to strong name”. But It also required to sign referenced DLLs, like BplusTree from http://bplusdotnet.sourcefo... I’ve ......

Custom HTTP response header to identify server in a farm.

We wanted to follow recommendation from http://omaralzabir.com/best... to“add “From” header and set the server name. I do this on each webserver and specify different names on each box. It’s handy to see from which servers requests are being served. When you are trying to troubleshoot load balancing issues, it comes handy to see if a particular server is sending requests” However one of the client of our rest service reported that From value in the response ......

Change DocType dynamically

I have a single page(created before Master pages were available) that loaded dynamically one or another user control.Some child controls have css for quirk mode, but for new controls I want to use latest DocType <!DOCTYPE html> The solution is to set it dynamically in code-behind depending on current control to load(the code is copied from http://stackoverflow.com/qu... =========aspx=============== <%@ Page Language="C#" ......

Changing “Trusted Sites” list affected HttpWebRequest in application running under different account

We have a webscraper ASP.Net application, that worked fine on developers and test environments, but didn’t work on some machines with more strict security settings. HttpWebRequest failed with System.Net.WebException: Unable to connect to the remote server It start working when my colleague added the site that application tried to access to his “Trusted Sites” zone using Internet Explorer. What we couldn’t understand, how it affected an application that ran under DIFFERENT account. I didn’t find any ......

Localization Approach for ASP.NET Web site

String Resources For string resources we will use local/global resources connecting to DB using DbResourceProvider from “Creating a Data Driven ASP.NET Localization Resource Provider and Editor” http://www.west-wind.com/pr... It also has DbResourceControl, that shows controls with Localizable attribute and connect them to editor. From http://guysmithferrier.com/... and http://www.guysmithferrier.... ......

How to disable IIS application pool

I wanted to disable a few web application on IIS server, running within the same application pool. I've opened the pool properties, but I didn't find the option to disable. I've tried to find in Google, but didn't find the answer. So I decided that changing identity to some not authorized user will be sufficient. Fortunately, my collegue told me, that to disable pool you need to STOP it. And pool will be stopped until you as Admin explicitely start it.- it is not re-started autiomatically after reboot. ......

Combining javascript files

I’ve read Combining Client Scripts into a Composite Script and wanted to use it. Then I’ve read Julian Jelfs concerns ScriptManager.CompositeScript issues However the article Combining javascript files with Ajax toolkit library describes workarounds, that make the solution workable. You also can use Script reference profiler: http://aspnet.codeplex.com/... Related posts: Using ScriptManager with other frameworks MSDN documentation: CompositeScriptReference The older implementations, ......

Message : A potentially dangerous Request.Path value was detected from the client (:).

We’ve noticed in event log the following error: Message : A potentially dangerous Request.Path value was detected from the client (:). Type : System.Web.HttpException, System.Web, Version=4.0.0.0, Culture=neutral, Message : A potentially dangerous Request.Path value was detected from the client (:). Source : System.Web WebEventCode : 0 ErrorCode : -2147467259 Stack Trace : at System.Web.HttpRequest.Vali... at System.Web.HttpApplication.... ......

Validation of Html file

We’ve used HtmlAgilityPack based function IsValidHtmlFragment(string html) to validate dynamically loaded Html Fragments before inserting into main page(or do not insert if it is invalid) and recently noticed that it doesn’t return false for some fragments with not closed tags. I decided to find some other tool to call from the code and found that most of HTML parcers are too forgivven(like browsers) or too strict- to check full XHTML conformance. I am going to add manual procedure to run Tidy.EXE ......

RemoveQueryStringFromUrl helper function

I've recently added to my UriHelper class the function RemoveQueryStringFromUrl public static string RemoveQueryStringFromUrl(st... url) { //similar to string qs = QueryStringHelper.QueryStri... string urlPath = url.LeftBefore("?"); return urlPath; } It refers to methods from My QueryStringHelper class and My StringHelper class ......

JavaScript function to Redirect parent of IFrame to specified URL

/// <summary> /// Redirects parent of IFrame to specified URL /// If current page doesn't have parent, redirect itself /// </summary> /// <param name="page"></param> /// <param name="url"></param> public static void NavigateParentToUrl(Page page, string url) { String script = @" try { var sUrl='" + url + @"'; if (self.parent.frames.length != 0) self.parent.location=sUrl; else self.location = sUrl; } catch (Exception) {} "; page.ClientScript.RegisterS... ......

Comment in JavaScript code doesn't comment the server command

Comment in JS code doesn't comment the server command. It is correct, but can be visually confusing. I had the following line in markup ASCX file. // var trs = document.getElementById('&l... %>').getElementsByTagNam... Visual Studio showed it as green comment. However when server control pnlOutsideSearch was renamed, the errors were generated, and it took me some time to realize, what wrong with the line, tha it was look like just comment ......

Full ASP.NET Archive

«November»
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456