I've set up a very basic ServiceStack project with Bootstrap and I'm trying to get it to see my homepage (Razor View) which it doesn't, so I get the Snapshot of my homepage. Here are the steps I take to create the project:
- Create new Project "ServiceStack ASP.Net with Bootstrap"
- Open Nuget Server Console to download misssing Servicestack Packages.
- Build.
- Renamed Services.cs to MyStuffServices.cs and Model.cs to MyStuffModel.cs
Added to 'AppHost.cs':
SetConfig(new HostConfig { DefaultRedirectPath = "/Home" });
Moved "_layout.cshtml" from /veiws/shared to /views folder
- Added "Home.cshtml" to /views
- Added minor text to Home.cshtml
Added to MyStuffService.cs
public class HomeService : Service { [DefaultView("Home")] public int Get(Home request) { return 0; } }
Added to MyStuffModel.cs:
[Route("/home", "GET")] public class Home : IReturn<int> { }
- Build.
- Run to Internet Explorer - Get Snapshot page.
Here is my AppHost.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Funq;
using ServiceStack;
using ServiceStack.Razor;
using MyStuff.ServiceInterface;
namespace MyStuff
{
public class AppHost : AppHostBase
{
/// <summary>
/// Default constructor.
/// Base constructor requires a name and assembly to locate web service classes.
/// </summary>
public AppHost()
: base("MyStuff", typeof(MyStuffServices).Assembly)
{
}
/// <summary>
/// Application specific configuration
/// This method should initialize any IoC resources utilized by your web service classes.
/// </summary>
/// <param name="container"></param>
public override void Configure(Container container)
{
//Config examples
//this.Plugins.Add(new PostmanFeature());
//this.Plugins.Add(new CorsFeature());
this.Plugins.Add(new RazorFormat());
SetConfig(new HostConfig
{
DefaultRedirectPath = "/Home"
});
}
}
}
Here is my Global.asax
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
namespace MyStuff
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
new AppHost().Init();
}
}
}
I have no errors and the Package Manager says I'm not missing any packages. I feel like there is a step I'm missing, any help is greatly appreciated.
Update: When executing with debug on, this is what I get when I open with Internet Explorer
@inherits ViewPage
@{
ViewBag.Title = "Hello World Service";
}
<div>
<div>
<input class="form-control input-lg" id="Name" type="text" placeholder="Type your name">
<p id="helloResult" style="margin-top: 15px;font-size: large"></p>
</div>
</div>
<script>
$('#Name').keyup(function () {
var name = $('#Name').val();
if (name) {
$.getJSON('/hello/' + name)
.success(function (response) {
$('#helloResult').html(response.Result);
});
} else {
$('#helloResult').html('');
}
});
</script>