Geeks With Blogs

Michael Freidgeim's Blog MS .Net Development 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 ......

Posted On Sunday, June 2, 2013 2:29 PM

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 ......

Posted On Saturday, October 6, 2012 12:49 PM

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 ......

Posted On Sunday, September 30, 2012 11:55 AM

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: ......

Posted On Friday, June 15, 2012 9:56 PM

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 ......

Posted On Wednesday, April 25, 2012 11:55 AM

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 ......

Posted On Sunday, April 15, 2012 8:08 PM

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... ......

Posted On Saturday, April 14, 2012 2:50 PM

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 ......

Posted On Saturday, April 14, 2012 10:40 AM

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 ......

Posted On Saturday, March 10, 2012 11:31 PM

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 ......

Posted On Saturday, March 10, 2012 10:51 PM

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#" ......

Posted On Friday, September 23, 2011 9:38 PM

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 ......

Posted On Saturday, September 10, 2011 7:45 AM

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.... ......

Posted On Saturday, July 2, 2011 9:00 PM

DropDownList.SelectedValue returns UpperCase string.
I've noticed that DropDownList.SelectedValue returns Upper Case string, even if Items in ListItemCollection are shown in mixed case in debugger and in html. I tried to confirm it using Reflector , but didn't find particular code to call ToUpper. Is it only my application or .Net framework(I am using 2.0) ? Anyway, it is a good practice to call ToUpper() if you want to compare DropDownList.SelectedValue with other strings ......

Posted On Monday, December 10, 2007 4:39 PM

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. ......

Posted On Wednesday, December 5, 2007 10:16 PM

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, ......

Posted On Sunday, June 26, 2011 6:27 AM

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.... ......

Posted On Thursday, June 9, 2011 7:42 AM

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 ......

Posted On Wednesday, June 1, 2011 6:36 AM

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 ......

Posted On Thursday, May 12, 2011 6:59 AM

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... ......

Posted On Friday, March 19, 2010 6:34 AM

Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net | Join free