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

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

Manipulation with cells, generated by GridView DataControlField derived classes.

I've previously posted "Access to BoundField value when GridView row is selected." Sometimes you need to customise DataControlField derived field (e.g. HyperLinkField or ButtonField )to show it differently then default behavior, but you don't want to create template for the field. If you customization requirements are compex, use TemplateField. Below there is an example, how you can access cell, generated by HyperLinkField and change content of the cell. E.g for HyperLinkField column you normally ......

Explicitely specify Default user credentials for Proxy Server.

Some time ago I wrote post "Call Web Services through SQuid proxy server with authentication requested" and hoped, that I will not have more problems with Squid web proxy server. However the solution wasn't sufficient for other site. I've tried a lot of things, started thread "Unable to access external web sites through Squid proxy server with required authentication." and posted suggestion to Microsoft "Add ability to specify credentials to defaultProxy configuration element". But the best solution, ......

legacyUnhandledExceptionPolicy enabled="true" doesn't prevent ASP.NET application restarting

We have an ASP.NET application in production(running IIS6 on Windows 2003 server) that sometimes has ".NET Runtime 2.0 Error Reporting" due to exceptions in background threads. We wanted to ignore the errors(while we will fix the cause) and specified <runtime> <legacyUnhandledExceptio... enabled="true" /> </runtime> in application web.config(as it is suggested in MSDN). Unfortunately it didn't help- ASP.NET application still keep restarting, which causes "session expired" behavior.I ......

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

Full ASP.NET Archive

«October»
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678