2
我似乎无法让我的服务自动路由,MetaData显示所有可用的类和服务,但是我应该去/ api/btbCustomerEvents我得到未处理的路由错误。ServiceStack MVC自动注册路由
我已经试过这样:
[Alias("btbCustomerEvents")]
[RestService("/btbCustomerEvents")]
public class Btbcustomerevent : BaseModel
我APPHOST看起来是这样的:
public class AppHost: AppHostBase
{
public AppHost() : base("Energy System API", typeof(DepartmentService).Assembly) { }
public override void Configure(Funq.Container container)
{
//Set JSON web services to return idiomatic JSON camelCase properties
ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;
//register all routes
Routes
.Add<Department>("/Departments")
.Add<Department>("/Departments/{Id}")
.Add<Paymentmethod>("/PaymentMethods")
.Add<Paymentmethod>("/PaymentMethods/{Id}")
.Add<MyExampleModel>("/MyExampleModel")
.Add<MyExampleModel>("/MyExampleModel/{Id}");
//Change the default ServiceStack configuration
SetConfig(new EndpointHostConfig{ DebugMode = true, });
container.Register<ICacheClient>(new MemoryCacheClient());
container.Register<ISessionFactory>(c =>
new SessionFactory(c.Resolve<ICacheClient>()));
ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
}
public static void Start()
{
new AppHost().Init();
}
我真的不希望在所有路由加入,我创建了创建模型TT文件从数据库中,也自动添加其余的服务/ CRUD风格,现在我不得不手动添加每个和每个路由,这似乎是一种耻辱。
任何人都有解决方案吗?
谢谢
嗨,我收到了错误:异常详细信息:System.Reflection.AmbiguousMatchException:属性名称不区分大小写:DbaIndexdefraglog.ErrorMessage但大小写和拼写正确?也尝试过使用服务,但得到相同的错误信息。我把代码放到了AppHost/Configure之前的其他路由之前,你可以更具体一些,谢谢 – davethecoder 2012-07-17 07:58:13
这是手动注册路由的替代品。即删除任何看起来像'/ {RequestDto}'和'/ {RequestDto}/{Id}'的路由,因为上面的代码行已经为指定程序集中的每个服务都做了这个。 – mythz 2012-07-17 16:28:36
你好,谢谢,是的,我做到了,它跌倒了,不喜欢一些表格,我只能升级代码而不是数据库到目前为止,我注意到的一件事是基础(“能源系统API” ,typeof(DepartmentService)不应该指向服务,所以我纠正了这一点,并修改了我的TT文件以自动添加RestService链接,感谢您的帮助 – davethecoder 2012-07-18 08:08:19