Breeze is not working with some project settings

2019-09-18 06:44发布

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?

2条回答
forever°为你锁心
2楼-- · 2019-09-18 06:56

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');
查看更多
孤傲高冷的网名
3楼-- · 2019-09-18 06:58

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

var mgr = new breeze.EntityManager('/breeze/Breeze');
查看更多
登录 后发表回答