(嵌入式)Raven Studio和我现有的MVC 4路由不能一起工作?

时间:2013-01-14 23:15:44

标签: c# asp.net-mvc ravendb

我是RavenDB和嵌入式内容的新手。我现在在Google上搜索了将近两个小时,但无法找到问题的解决方案;可能是因为我仍然是RavenDB n00b: - )

我的文档存储的初始化看起来像这样,工作正常(我可以查询文档):

IocContainer.Instance.RegisterSingle(() =>
{
    var ds = new EmbeddableDocumentStore {DataDirectory = "Data", UseEmbeddedHttpServer = true};
    return
        ds
            .Initialize()
            .OpenSession();
});

在前一个或两个请求中,路由工作就像我期望的那样,所以我最终在我的HomeController上。经过另一次刷新后,我结束了/raven/studio.html?...太棒了!但不是我期望降落的地方!

如果我然后将URL更改为/ Home,就像我的控制器一样,我会看到这个结果:

Could not figure out what to do
Your request didn't match anything that Raven knows to do, sorry...

当然,当我删除UseEmbeddedHttpServer时,它的工作方式与以前一样,但这不是我想要的。我希望能够浏览文档。

我的默认MVC生成RouteConfig,*添加到{id}:

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{*id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }
}

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:4)

关闭RavenDb中的内部Http服务器或将RavenDb-http-server映射到另一个端口

1:

var ds = new EmbeddableDocumentStore {
   DataDirectory = [DataFolder],
  UseEmbeddedHttpServer = false
};

2:

int ravenPort = 8181;
NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(ravenPort);
var ds = new EmbeddableDocumentStore {
   DataDirectory = [DataFolder],
   UseEmbeddedHttpServer = true,
   Configuration = {Port = ravenPort}
};

案例2现在可以在端口8181上访问Raven Studio,而不是映射到您网站的端口(80)