w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to register a url protocol handler in Node.js
First of all creating your own protocol is crazy, don't do that. It seems all you want to do is to be able to launch you node package from a web-browser. The normal way to launch a external program from a web-browser is to write a browser plugin. This is how pdf, torrents, iTunes get launched from your browser. So in summary to do what you want you will have to write a plugin and get your users to install. Not particualy a good idea I would say.

Categories : Javascript

Umbraco surface controller inside v6 project
A couple of things here: You no longer need to end the name of you controller "SurfaceController", just inherit from SurfaceController. Also you wouldn't need the path prefix /Umbraco/surface/, you should be able to access the Index() action just at /my/, if your controller was called the MyController. Edit: Assuming that you want to serve pages from your controller, you will need to amend the web.config AppSetting entry to include your controller's path <add key="umbracoReservedPaths" value="~/umbraco,~/install/,~/my" /> You will also need to register a route specifically for your controller from the global.asax: routes.MapRoute( name: "Default", url: "my/{action}/{id}", defaults: new { action = "Index", id = UrlParameter.Optional } ); It's important that this

Categories : C#

Register Autofac decorator for only one generic command handler
After smacking my head against keyboard enough times, I've got some kind of solution to my problem: static class AutofacRegistration { public static IContainer RegisterHandlers() { var builder = new ContainerBuilder(); builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(AutofacRegistration))) .AsClosedTypesOf(typeof(ICommandHandler<>)) .InstancePerLifetimeScope(); builder.RegisterType<TestCommandHandler>() .Named<ICommandHandler<TestCommand>>("TestHandler") .InstancePerLifetimeScope(); // this works! builder.Register(c => new TestCommandHandlerDecorator(c.ResolveNamed<ICommandHandler<TestCommand>>("TestHandler"))) .As<IComm

Categories : C#

HTTP GET to return custom model with data from external database with Umbraco MVC Surface Controller
There are a lot of questions about this and the best place to look for an authoritative approach is the Umbraco MVC documentation. However, yes you will find, if you use Html.BeginUmbracoForm(...) you will be forced into a HttpPost action. With this kind of functionality (a search form), I usually build the form manually with a GET method and have it submit a querystring to a specific node URL. <form action="@Model.Content.Url"> ... </form> On that page I include an @Html.Action("SearchResults", "TyresSearch") which itself has a model that maps to the keys in the querystring: [ChildAction] public ActionResult(TyreSearchModel model){ // Find results TyreSearchResultModel results = new Wheels.BDL.TyreBDL().GetAllTyres(); // Filter results based on submitted mo

Categories : Asp Net Mvc

Register custom protocol handler on Win8 in Delphi 7/2006 app
Is there any way to do this silently (so the user doesn't have to click around the UI) MSDN: The file type and protocol association model has changed in Windows 8. Apps are no longer able to programmatically set themselves as the default handler for a file type or protocol. Instead, now the user always controls what the default handler is for a file type or protocol. Some help links: http://borland.newsgroups.archived.at/public.delphi.nativeapi.win32/200611/0611216695.html I think you have some error on your register entries, so its good to post it if you can.

Categories : Windows

Register same Unity interception & call handler for all registered types
Unity 3 provides registration by convention which could help in this scenario: IUnityContainer container = new UnityContainer(); container.AddNewExtension<Interception>(); container.RegisterTypes( AllClasses.FromLoadedAssemblies().Where( t => t.Namespace == "My.Namespace.Services"), WithMappings.MatchingInterface, getInjectionMembers: t => new InjectionMember[] { new Interceptor<InterfaceInterceptor>(), new InterceptionBehavior<MyBehavior>() }); } You could combine the above with Policy Injection to use matching rules to wire up your call handler. That way you could use a variety of matching rules instead of (or in combination with) attributes to determine which call handlers go with which classes/methods. container

Categories : C#

Serve static files through a custom handler or register in app.yaml?
Use the static handler: You don't need to startup an instance to serve your file. This generally means it'll be served quicker, and you save on CPU hours. You don't have to worry edge caching. The cons might be that the files are static, and it might require more manual intervention with your framework.

Categories : Python

In Umbraco 6.1.1 MVC 4, how can I do a form post back to a surface controller using a model that inherits from Umbraco's RenderModel?
Ok, I've had no responses to this question but am now in a position to answer it myself. Maybe it was a fundamental oversight, but not that obvious imho, and information on the Umbraco forum etc about inheriting from RenderModel is fairly limited. Essentially the answer, as was my first instinct, is to solve the original exception "No parameterless constructor defined for this object" by providing a paramaterless constructor. The difficulty is working out what to put inside the parameterless constructor for my model, since it inherits from the Umbraco RenderModel which requires an IPublishedContent instance passed to it's constructor. Luckily while browsing around I happened across this post on the Umbraco forum: http://our.umbraco.org/forum/developers/api-questions/40754-Getting-Curre

Categories : Asp Net Mvc

Register event handler for Ajax (Bootstrap-Tree) loaded checkboxes
You can use DOMSubtreeModified and unbind $("#divId").bind("DOMSubtreeModified", function() { alert("dom tree changed"); $(":checkbox").unbind('change').bind('change', function () { // your binding code }); });

Categories : Jquery

Umbraco MVC Implementation - View does not depend on Umbraco implementations
No you can't. Simply because all requests pass through a single action. In order to retrieve a path to a CMS-managed page, you need to use the node/content traversal the @Model provides. See here for more details on this. Edit To clarify, the author of the article is suggesting that the Umbraco implementation should be more in line with a traditional MVC implementation with little or no logic in the views. Therefore, any querying of node data should happen prior to the view (e.g. in the Mappers). So this is where you would have to retrieve the links. Umbraco's default MVC implementation forces all requests to go via a single action on a single controller. The author's implementation allows the requests to be shared across one controller per document type - which is better IMO. But it st

Categories : Asp Net Mvc

How to register a System Supplied Property Handler for XPS and OPC files in registry for a custom file type?
You have to: Create a key named with your extension (e.g. a key named .doc) under HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionPropertySystemPropertyHandlers. Then set the default value for the key you just created to {45670FA8-ED97-4F44-BC93-305082590BFB} Under Root/SystemFileAssociations add a key named with your file extension (e.g. .doc). Under that key add "shellexPropertyHandler" Set default value under the PropertyHandler key to {45670FA8-ED97-4F44-BC93-305082590BFB}. Now you have to tell Windows what properties to display depending on circumstance. Add FullDetails, PreviewDetails, ExtendedTileInfo, and InfoTip keys to the Root/SystemFileAssociations/ key. This property handler is good for both OPC (open package conventions) and XPS files. PreviewDetails

Categories : Misc

Umbraco MediaService / Umbraco MediaItem not saving
To Save media, I found this method with MediaService. However, I think it's possible another method more refined [HttpPost] public JsonResult Upload(HttpPostedFileBase file) { IMedia mimage; // Create the media item mimage = _mediaService.CreateMedia(file.FileName, <parentId>, Constants.Conventions.MediaTypes.Image); mimage.SetValue(Constants.Conventions.Media.File, file); _mediaService.Save(mimage); return Json(new { success = true}); }

Categories : C#

Umbraco - error when using umbraco.library:NiceUrl(...)
Ok I found a solution: I added an extra check to this part: <!-- Return the url --> <xsl:if test="$i = $max"> <xsl:if test="$id != '' "> <xsl:value-of select="umbraco.library:NiceUrl($id)" /> </xsl:if> </xsl:if> this fixed my problem.

Categories : Xslt

android-async-http library get http response header from Response Handler
@Zapnologica, it seems, that author of library provided changes based on this pull request: https://github.com/loopj/android-async-http/pull/170 But it is not released yet, at least latest available .jar version of library is 1.4.3 and it does not include these changes, unfortunately. The only option we may try to use is cloning/forking git repo and including its sources into your project. UPDATE: Seems library will soon be added to maven central repo, but at least now I was able to add 1.4.4 SNAPSHOT build using gradle for my project with such config changes: repositories { ... //android-async-client repo maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } } And then in dependencies section: compile 'com.loopj.android:android-async-http:1.

Categories : Android

Register GCM from a library project
Here's what you have to do : Write a class (in your library project) that overrides GCMBroadcastReceiver : package com.test.pushlibrary; import android.content.Context; import com.google.android.gcm.GCMBroadcastReceiver; public class PushLibraryBroadcastReceiver extends GCMBroadcastReceiver { /** * Gets the class name of the intent service that will handle GCM messages. */ @Override protected String getGCMIntentServiceClassName(Context context) { return "com.test.pushlibrary.GCMIntentService"; } } Change your manifest to refer to the new receiver : <receiver android:name="com.test.pushlibrary.PushLibraryBroadcastReceiver" ... The reason that your original code didn't work is that the default implementation of getGCMIntentS

Categories : Android

Could not locate Razor Host Factory type: umbraco.MacroEngines.RazorUmbracoFactory, umbraco.MacroEngines
If you are trying to host the blogengine site within a virtual directory of the Umbraco site, then you will have to amend the blogengine web.config to "remove" all the Umbraco-specific handlers and modules, as these will be inherited by the blogengine application, causing this exception because the application can't find the relevant DLLs in its bin folder. I recently had a similar problem and I have posted the web.config I used in the virtual directory below. Mine was a very simple web application, so obviously this will not work by itself in your blogengine app. You will need to add the relevant parts into your web.config file. Also, this was for a v6 Umbraco install in IIS7.5, so you may have to experiment a little. <?xml version="1.0"?> <configuration> <configSecti

Categories : Iis

http handler does no work in MVC IIS 8.0
Just in case you want to use the Mvc Routing here is an implementation of the custom route handler for ManagedFusion.Web.CaptchaImageHandler. public class CaptchaRouteHandler:IRouteHandler { public System.Web.IHttpHandler GetHttpHandler(RequestContext requestContext) { return new ManagedFusion.Web.CaptchaImageHandler(); } } Then, your route definition in RouteConfig.RegisterRoutes define the custom route: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.Add( "Captcha Route", new Route( "captcha.ashx", new CaptchaRouteHandler())); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", def

Categories : Asp Net

Cannot register C++/CLR .NET Project after moving from VS2008 to VS2010
Have you tried with: C:WINDOWSMicrosoft.NETFramework64v2.0.50727RegAsm.exe "C:ProjectAnalystIDA_plugin_PrecursorScan_OpenFileOnce_VCPPAnalyst_UserIDADebugAnalyst_UserIDA.dll" /tlb:Analyst_UserIDA.tlb /codebase ?

Categories : Dotnet

http handler not showing image
You should use that if (context.Request.QueryString["Name"] != null) { querySqlStr = "SELECT Photo from UserProfile where UserName= @username" ; } conn = new SqlConnection(connString); SqlCommand command = new SqlCommand(querySqlStr, conn);. command.Parameters.Add("@username",context.Request.QueryString["Name"]); But as you have it must be with single quotes querySqlStr = "SELECT Photo from UserProfile where UserName='" + context.Request.QueryString["Name"] + "'"; As i said in my comment DO NOT USE string concatenation. You will gain many things. But i think your problem is that you are trying to put in ImageUrl byte[]. It just need path. See this http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.image.imageurl.aspx If you want to loa

Categories : C#

Doesn`t run http handler in asp.net application
If you're in classic mode, then asp.net won't get called by IIS unless IIS knows the file type that should get mapped. In your IIS control panel, you should be able to configure the file types handled by ASP.NET. Otherwise, it's going to assume that a file type is for a physical file, which it can't find on the file system.

Categories : C#

How to pass type into an http handler
use a closure. in app/c change Index to: func Index(db *sql.DB) func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) { // do stuff with db here fmt.Fprintf(w, "Hello world!") } } then in your main function use it like so: r.HandleFunc("/", c.Index(db)) The Index function returns an anonymous function that fits the the HandleFunc type and also closes over the value of the db that was passed in giving your handler access to that variable.

Categories : Go

How to Reference HTTP Handler from UserControl
I couldn't understand what exactly you need here. But You can load image from user control using below code. using System.Web; using System.Web.UI; using System.IO; namespace WebApplication1 { public class ImageHandler : Page, IHttpHandler { public new void ProcessRequest(HttpContext context) { context.Response.Clear(); ChartCtl chartCtl = (ChartCtl)LoadControl(ResolveClientUrl("ChartCtl.ascx")); MemoryStream ms = new MemoryStream(); ms = chartCtl.renderChart(ms); context.Response.Clear(); context.Response.ContentType = "image/jpeg"; context.Response.BinaryWrite(ReadFully(ms)); context.Response.End(); } public static byte[] ReadFully(Stream input)

Categories : C#

Custom HTTP handler not working in .NET
Although it is very unclear to understand what you are trying to do, please note that SharePoint provide this feature out-of-the-box. For example, if you PDF is located at : http://yourserver/documents/somedocument.pdf You can get a forced download of the file using: http://youserver/_layouts/download.aspx?SourceUrl=/documents/somedocument.pdf

Categories : Dotnet

FileServer handler with some other HTTP handlers
You need to use the http.StripPrefix handler: http.Handle("/files/", http.StripPrefix("/files/", http.FileServer(http.Dir(".")))) See here: http://golang.org/pkg/net/http/#example_FileServer_stripPrefix

Categories : Go

How to register event handler for WebBrowser.ScriptNotify Event
Define a function in your btn handler: <button onclick='function(){ window.external.Notify('clearTextBox'); }'>clear textbox</button> In XAML define ScriptNotify handler and set IsScriptEnabled = true, for example: <phone:WebBrowser x:Name="Browser" IsScriptEnabled="true" ScriptNotify="BrowserScriptNotify"> </phone:WebBrowser> Add event handler to code behind: private void BrowserScriptNotify(object sender, NotifyEventArgs e) { //Do your business here }

Categories : C#

How to write the response to a file in HTTP Handler
Well, the documentation is pretty straight forward about this: The [SaveAs] call specifies that the request be saved as a text file in a directory where the ASP.NET process identity has been granted write permissions, and that any header information included in the request is included in the file. You can thus simply save the entire HttpRequest (including the headers in a file). You can simply determine the path and a boolean indicating whether you want to incude the headers as well: context.Request.SaveAs(@"c://myLogFile.log",true)

Categories : C#

ActiveReports HTTP handler shared hosting
In case you are facing issues related to permissions, then I would suggest you to run the application on MediumTrust. Please refer to the following documentation link that will guide you through: http://helpcentral.componentone.com/nethelp/AR7Help/OnlineEn/arMediumTrustSupport.html On further searching, I found the following link wherein a similar issue has been discussed on the godaddy’s support page. This might be informative for you: http://support.godaddy.com/groups/web-hosting/forum/topic/request-to-add-arcacheitem-handler-to-iis/

Categories : Asp Net

Background thread created in http handler
Yes. They're all part of the same application domain that dies with the worker process. With a normal Thread if not marked as IsBackground it will basically hold the process open until it completes. If you have overlapping worker processes enabled (true by default) this isn't a problem for new requests coming in as a new process will start, but if you have it turned off it will wait until the existing one quits, basically halting the site. So really if you want them to live longer you either have to increase timeouts or have them handled by some external process using IPC etc.

Categories : C#

not working loader complete handler if url has only http://abc.com
This is possibly a security sandbox issue. See here for a similar issue and resolution - http://www.kirupa.com/forum/showthread.php?357992-www-works-without-www-doesn-t-problem-with-URLRequest#post_2587691

Categories : Actionscript

"http://{root_dir}/oauth/token" File Not Found in Magento to register REST API application
First of all you need to install oauth extension for php, if it's already install than check your phpinfo that it's enabled. Than go to admin section and make the following changes to check the response of rest api. admin->system->Webservice->rest attribute->guest->resources access and set ALL admin->system->webservice->rest roles->guest->resources access and set ALL save the settings and hit your url http://hostname/magento/api/rest/products/ it will show you the response in xml format.later on modify the resource access as per your requirement. once you make sure that magento is responding to the reset api than run your code and I feel it will work.

Categories : PHP

Using Goroutines for background work inside an http handler
Go multiplexes goroutines onto the available threads which is determined by the GOMAXPROCS environment setting. As a result if this is set to 1 then a single goroutine can hog the single thread Go has available to it until it yields control back to the Go runtime. More than likely doSomeBackgroundWork is hogging all the time on a single thread which is preventing the http handler from getting scheduled. There are a number of ways to fix this. First, as a general rule when using goroutines, you should set GOMAXPROCS to the number of CPUs your system has or to whichever is bigger. Second, you can yield control in a goroutine by doing any of the following: runtime.Gosched() ch <- foo foo := <-ch select { ... } mutex.Lock() mutex.Unlock() All of these will yield back to the Go ru

Categories : Go

curl http handler for solarium solr error
As already mentioned, it looks like the cURL extension is not installed on his system, so either install it if possible, or in case it's just disabled, enable it, or simply use a different adapter. https://github.com/basdenooijer/solarium#requirements Requirements Solarium only supports PHP 5.3 and up. It's highly recommended to have Curl enabled in your PHP environment. However if you don't have Curl available you can switch from using Curl (the default) to another client adapter. The other adapters don't support all the features of the Curl adapter. HTTP Adapter https://github.com/basdenooijer/solarium/blob/master/examples/6.1.4-http-adapter.php ... // create a client instance $client = new SolariumClient($config); // set the adapter to http $client->setAdapter('Solari

Categories : PHP

Angular: Default handler for unhandled http errors
Assuming that you know which errors needs to be suppressed and which one need to be propagate. Also since the Response interceptor is a function that returns promise itself You can catch the response for failure case and instead of propagating it up the stack you can return something such as empty response. If you look at the sample example in angular documentation for interceptor $provide.factory('myHttpInterceptor', function($q, dependency1, dependency2) { return function(promise) { return promise.then(function(response) { // do something on success }, function(response) { // do something on error if (canRecover(response)) { return responseOrNewPromise; // This can suppress the error. } re

Categories : Javascript

How can I safely handle POST parameters in an HTTP Handler using C#?
There is nothing wrong with omitting parameters to an endpoint. As the developer you are in charge of enforcing what the client is allowed send to you. If you expect a parameter and it's missing, throw an error (e.g. HttpException). If you are creating or updating data (i.e. inserting or updating records in a database) the best method would be a POST or PUT. Edit - Here is an example of how you can handle the input: public void ProcessRequest(HttpContext context) { //Maybe you require a value? if (string.IsNullOrEmpty(context.Request["something"])) { throw new HttpException(400, "You need to send a value!"); } //Maybe you require a certain value? if (context.Request["something"] != "beerIsGood") { throw new HttpException(400, "You need to send the

Categories : C#

Calling ASP.Net HTTP handler on click of checkbox in Rad Grid
$(document).ready(function () { $("#<%=RadGrid1.ClientID%> input[id*="HeaderCheckBox1"]:checkbox").click(function () { // write code http handler alert("Checked"); }); Then write code for calling the http handler for more info go through following link http://brijbhushan.net/2011/05/29/call-httphandler-from-jquery-pass-data-and-retrieve-in-json-format/

Categories : Javascript

node.js http-proxy how to set timeout and a handler on request
You may want to try this : proxy.on('error', function(err, preq, pres){ pres.writeHead(500, { 'Content-Type': 'text/plain' }); pres.write("An error happened at server. Please contact your administrator."); pres.end(); });

Categories : Node Js

Get the Http response status using 'httpClient(postRequest,Handler)' method
Is there any way to use the first method, and still be able to get the the Response status? No. Here's what you do HttpResponse response = httpclient.execute(request); ResponseHandler handler = ...; String JSONResult = handler.handleResponse(response); StatusLine status = response.getStatusLine(); Now you have access to the status from the HttpResponse object and are able to process the response with a ResponseHandler to get the json result. The point of the different methods is that you don't really care about the status, only the handled response.

Categories : Java

How to get label's text by HTTP handler (.ashx) in repeater control
If you are not married to the idea of using an HTTP Handler, then I suggest making a method in your .aspx page's code-behind that does the same logic your handler is doing minus the content-type stuff, like this: protected string GetName(int pro_id) { return DBHelpername.name(pro_id); } Now in your markup you can use this method, like this: <asp:Label ID="Label1" runat="server" Text='<%# GetName((int)Eval("id")) %>'> </asp:Label>

Categories : Asp Net

Setting a custom cookie in the HTTP headers inside a SOAP Message handler
We also needed to get a JSESSIONID recent - and to pass it back in subsequent requests. Using various different answers (mostly from StackOverflow and an example of an SSO client on the IBM site) we extended SOAPHandler to do it: import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.List; import javax.xml.ws.handler.MessageContext; import javax.xml.ws.handler.soap.SOAPHandler; import javax.xml.ws.handler.soap.SOAPMessageContext; import com.sun.istack.internal.Nullable; public class SoapMessageHandler implements SOAPHandler<SOAPMessageContext> { private String sessionCookie = ""; @Override public void close(MessageContext arg0) { } @SuppressWarnings({ "rawtypes", "unchecked" }) @Override publi

Categories : Java

How to define a handler for http errors when loading view content using ngView in AngularJs
Maybe you can use the $routeChangeError event. This event will be emitted i.a. if the template can't be loaded.

Categories : Javascript



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.