Breeze is not working with some project settings

邮差的信 提交于 2019-12-12 05:35:10

问题


I have a problem using breeze on a project based on John Papa's HotTowel. I configured breeze like:

var mgr = new breeze.EntityManager('breeze/Breeze');

everything is ok but in the case I change the Project properties Start Action from Current Page to Specific Page: HotTowel/Index and breeze doesn't work properly.

I've checked the requests using firebug. It seems in this case application sends a GET request like this:

http://localhost:53180/HotTowel/Index/breeze/Breeze/Metadata

instead of

http://localhost:53180/breeze/Breeze/Metadata

I've also checked this part of breeze.js which is going to send get request. The url parameter is set to breeze/Breeze/Metadata in both cases which seems correct.

  ctor.prototype.fetchMetadata = function (metadataStore, dataService) {   
  var serviceName = dataService.serviceName;
  var url = dataService.makeUrl("Metadata");
  var deferred = Q.defer();
  var that = this;
  ajaxImpl.ajax({
  url: url,
  dataType: 'json',...

I've also tried ~/breeze/Breeze but it didn't work as remote service name.

As I'm new to web, probably it's not related to breeze. The question is why the ajax call (or breeze) depends on how the project activates?


回答1:


Add a / character to your configuration to execute the request relative to the base directory:

var mgr = new breeze.EntityManager('/breeze/Breeze');



回答2:


The reason why this happens is because you specified a relative path for the EntityManager and if your url is localhost:53180/HotTowel/Index then the relative url for the EntityManager is localhost:53180/HotTowel/Index + /breeze/Breeze.

To correct the issue, change your EntityManager path to the following:

var mgr = new breeze.EntityManager('breeze/Breeze');


来源:https://stackoverflow.com/questions/17337292/breeze-is-not-working-with-some-project-settings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!