Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dotnet-websharper/webapi
Wrappers for hosting WebSharper sitelets and remoting components in WebAPI projects
https://github.com/dotnet-websharper/webapi
Last synced: 8 days ago
JSON representation
Wrappers for hosting WebSharper sitelets and remoting components in WebAPI projects
- Host: GitHub
- URL: https://github.com/dotnet-websharper/webapi
- Owner: dotnet-websharper
- License: other
- Created: 2013-10-02T21:21:09.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-02-06T19:28:10.000Z (almost 11 years ago)
- Last Synced: 2023-05-10T20:35:19.699Z (over 1 year ago)
- Language: F#
- Size: 188 KB
- Stars: 6
- Watchers: 11
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# WebSharper.WebApi
Wrappers for hosting [WebSharper][ws] sitelets and remoting components
with [ASP.NET Web API][webapi]. It is designed to work with
WebSharper 2.5.* [NuGet][nuget] identifier: `WebSharper.WebApi`
* [Git sources at GitHub][gh]
* [Mercurial sources at Bitbucket][bb]
* [License][license]
* [Issue tracker][issues]## Usage
Hosting WebSharper code with ASP.NET Web API has the following
purposes:1. Using WebSharper in ASP.NET MVC4 projects
2. Hosting WebSharper as a part an [OWIN][owin] application, to
make it portable between IIS and other containers### ASP.NET MVC4
Follow these steps to get started with ASP.NET MVC4 and WebSharper:
1. Create an ASP.NET MVC4 project (or use an existing one).
2. Using NuGet package manager, install the `WebSharper.WebApi`
package. This will also install Microsoft Web API as a dependency.3. Create or use an existing WebSharper project defining a `Sitelet`
value.4. Configure your application to set up WebSharper.WebApi components
on initialization (see below).### OWIN / Standalone Use
Please see the provided example under `examples/`.
## Configuration
For ASP.NET MVC4, all initialization code should be called on `Application_Start`, for
example by placing it in `Global.asax`:```csharp
using System.Web.Http;
using IntelliFactory.WebSharperWebApi;public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
// ...
}
}
```In self-hosted applications, the initialization should be performed
before the application starts.To enable support for WebSharper remoting, which installs server-side
handlers to requests generated by calling `[]`-annotated
methods from client-side code, do:```csharp
RemotingHost.Register(GlobalConfiguration.Configuration);
```To host a sitelet, do:
```csharp
SiteletHost
.Configure(GlobalConfiguration.Configuration)
.WithDebug(true)
.WithServerRootDirectory(Server.MapPath("~"))
.Register(MyNamespace.MyModule.MySitelet);
```You may also specify a URL prefix, for example by doing
`.WithUrlPrefix("websharper")`. The sitelet virutal path space will
then be found under `~/websharper`.Sitelet hosting currently uses the router tables, so the order in of
registration matters in cases when you have non-WebSharper routers.* When registering the sitelet at root position, register other routes
before the sitelet registration and make them specific
(`mycontroller/{action}/{id}`, not `{controller}/{action}/{id}`.* When registering the sitelet with an URL prefix, register it before
other routes. In this case, other routes can capture arbitrary
patterns.[bb]: http://bitbucket.org/IntelliFactory/websharper.webapi
[gh]: http://github.com/intellifactory/websharper.webapi
[issues]: http://github.com/intellifactory/websharper.webapi/issues
[katana]: https://katanaproject.codeplex.com
[license]: http://github.com/intellifactory/websharper.webapi/blob/master/LICENSE.md
[nuget]: http://nuget.org
[owin]: http://owin.org
[webapi]: http://www.asp.net/web-api
[ws]: http://github.com/intellifactory/websharper