Earlier music projects and historical technical notes are collected in the Archive.
Prefer browsing by topic? See all categories.
Earlier music projects and historical technical notes are collected in the Archive.
Prefer browsing by topic? See all categories.
Sometimes you need to schedule tasks in ASP.NET and save both a Start Date and an Interval, stored respectively as DateTime and TimeSpan.Ticks in your database. Editing raw tick values is not exactly good UX, so I bound the proper MetaColumn to the proper UIHint. After some tests, I noticed the GUI was functional but not as intuitive as expected. The solution was to customize the FieldTemplateUserControl of Dynamic Data, to display and save multiple columns I needed (Start Date, Start Time, Occurs – Daily, Weekly, Monthly, etc.). ...
When working with ASP.NET you may need to increase the default limit for file uploads. By editing the Web.config file you can allow larger payloads. Example configuration: <configuration> <system.web> <httpRuntime executionTimeout="240" maxRequestLength="16384" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" enableVersionHeader="true" /> </system.web> </configuration> This configuration allows the upload of files up to 16 MB. Note (2025): The default settings and limits may have changed in more recent versions of ASP.NET/.NET. Check the Microsoft documentation for updated guidance. ...
In the web application that I’m developing using Dynamic Data, I set the DataContext at runtime. The application might bind different contexts depending on many variables. I usually test it on two different browsers, and, because of the session, I need to pass the same procedure twice. The second time, the DataContext is already set, so I don’t need to register the context anymore. The simple condition I use: if (System.Web.DynamicData.MetaModel.Default == null) { // Register context and routes ... } Otherwise I would get this exception: ...
Note (2025): This article dates back to 2008 and refers to ASP.NET Dynamic Data, which is legacy today. Concepts can still be useful historically, but for modern .NET consider newer frameworks and data‑binding approaches. The following snippet customizes the .NET ConnectionString at runtime in a Dynamic Data application. Edit Global.asax and modify the RegisterRoutes(RouteCollection routes) method. Instead of: model.RegisterContext(typeof(XYZDataContext), new ContextConfiguration() { ScaffoldAllTables = true }); Use: model.RegisterContext( () => new XYZDataContext(connectionString), new ContextConfiguration { ScaffoldAllTables = true } ); Where connectionString is your string value. You can customize the RegisterRoutes parameter collection without compromising application functionality.
In my scenario a .NET webservice offers particular encrypting capabilities. I need to consume the webservice with PHP by sending my plain string to get an encrypted one in return. The .NET webservice is working properly. I found the NuSoap library, and adopted it. Here the inclusion: require_once('lib/nusoap.php'); And here the code: // requires web service's specifications aka wsdl // $parameters: // requires following the array 'notation' // array('parameters' => (array('text' => 'Hello World!!!'))); // that equals to Hello World!!! // $proxy (->host, ->port, ->username, ->password) // optional, uses a proxy server function consume_webservice($wsdl, $method, $parameters, $debug = false, $proxy = null) { if ($proxy != null) $proxy->host = $proxy->port = $proxy->username = $proxy->password = false; $client = new soapclient($wsdl, true, $proxy->host, $proxy->port, $proxy->username, $proxy->password); $err = $client->getError(); if ($err) echo 'Constructor error' . $err; $result = $client->call($method, $parameters); // check for a fault if ($client->fault) { echo 'Fault'; print_r($result); } else { // check for errors $err = $client->getError(); if ($err) echo 'Error' . $err; } if ($debug) { echo 'Request' . htmlspecialchars($client->request, ENT_QUOTES); echo 'Response' . htmlspecialchars($client->response, ENT_QUOTES); echo 'Debug' . htmlspecialchars($client->debug_str, ENT_QUOTES); } return $result; } This approach works only with SOAP webservices. Please note that .NET web services include all response content into a “parameters” section by design.
The ModalPopup extender usually requires a control for firing up, set through the TargetControlID property. However, sometimes you may want to show and hide the panel programmatically. All you need is a fake activator, like the following: The Extender <ajax:ModalPopupExtender ID="mpeInfo" runat="server" TargetControlID="divFakeActivator" PopupControlID="pnlInfo" CancelControlID="bttInfoClose" /> The Panel <asp:Panel ID="pnlInfo" runat="server"> Hello World!!! </asp:Panel> The C# code // Show and hide programmatically mpeInfo.Show(); mpeInfo.Hide(); Note (2025): This post reflects an older ASP.NET AJAX pattern. In modern frameworks you would likely manage modal dialogs through client‑side libraries (e.g., Bootstrap, React, Blazor components). ...
My web app needs to catch every non‑existent path as a search string, because I’m implementing an HttpModule that handles URLs in an SEO‑friendly way, e.g.: http://contoso.com/search-string But the Microsoft AJAX ScriptModule interfered, causing runtime errors like “AJAX Framework failed to load…”. The fix was to register my module after the ScriptModule and selectively bypass AJAX requests. <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, ..." /> <add name="MyModule" type="MyModule" /> using System; using System.Linq; using System.Web; public class MyModule : IHttpModule { public void Init(HttpApplication context) { context.PostResolveRequestCache += Application_OnAfterProcess; } private void Application_OnAfterProcess(object source, EventArgs e) { var application = (HttpApplication)source; var context = application.Context; if (context.Request.Headers["x-microsoftajax"] == null) { if (!System.IO.File.Exists(application.Request.PhysicalPath) && !application.Request.Url.ToString().Contains(".axd") && !application.Request.Url.ToString().Contains(".asmx")) { string newUrl = "~/Search.aspx?q=" + context.Server.UrlEncode(application.Request.Url.Segments.Last()); // other logic here… context.RewritePath(newUrl); } } } public void Dispose() { } } This runs at PostResolveRequestCache and, when the special x-microsoftajax header is absent, it rewrites unknown paths to your search page while letting AJAX handlers (*.axd, *.asmx) pass through normally.
Allow Google Analytics to help understand how this site is used? Analytics stays off unless you accept. You can change your choice using Cookie settings. Privacy policy