I have an Asp.net web form which uses web API to transfer files, when user selects files by an <input type="file" />
, an Ajax function is called:
var ajaxRequest = $.ajax({
type: "POST",
url: './api/fileupload/uploadHugeFile',
contentType: false,
processData: false,
data: FD
});
Then in Global.asax
, in Application_Start
I added:
GlobalConfiguration.Configure(config =>
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = System.Web.Http.RouteParameter.Optional }
);
});
It's obvious that if I add a class named fileuploadController.cs in App_Code folder and create an uploadHugeFile() public method as an action, it works like a charm.
The problem is when I want to make this a control in company with many other controls to create a single dll file (using class library).
This should be referenced by a namespace then, the question is how can I add that namespace instead of url: './api/fileupload/uploadHugeFile'
, I thought of something like the namespaces: new[] {"MyNameSpace"}
at the end of MapHttpRoute()
.
Aucun commentaire:
Enregistrer un commentaire