Close

Catalog7SpikesController Wrapper and System.Web.Mvc Version 65535.65535.65535.65535

kev83
8 years ago
#11933 Quote
Avatar
  • 5
We created a custom CatalogController which returns a specific custom model. This works fine, until we try to use Nop Ajax Filters, because an incorrect model is returned by getFilteredProducts. So I thought, I'll just create a wrapper for Catalog7SpikesController, change the route in the view and be done with it. 

I had in mind something like this:


public partial class StrelliCatalog7SpikesController : BasePublicController {




  private readonly Catalog7SpikesController _catalog7SpikesController;




  public StrelliCatalog7SpikesController(
    ICategoryService categoryService,
    //... omitted for brevity ...//
    ICacheManager cacheManager,
    IProductServiceNopAjaxFilters productServiceNopAjaxFilters,
    IPriceCalculationServiceNopAjaxFilters priceCalculationServiceNopAjaxFilters,
    IFiltersPageHelper filtersPageHelper,
    NopAjaxFiltersSettings nopAjaxFiltersSettings,
    IQueryStringBuilder queryStringBuilder,
    IQueryStringToModelUpdater queryStringToModelUpdater,
    ICategoryService7Spikes categoryService7Spikes
  ) {
    _catalog7SpikesController = new Catalog7SpikesController(
      categoryService, //... omitted for brevity ...//
      cacheManager, productServiceNopAjaxFilters, priceCalculationServiceNopAjaxFilters,
      filtersPageHelper, nopAjaxFiltersSettings, queryStringBuilder, queryStringToModelUpdater,
      categoryService7Spikes
    );
  }




  public ActionResult GetFilteredProducts(
    int categoryId, int manufacturerId, int vendorId,
    PriceRangeFilterModel7Spikes priceRangeFilterModel7Spikes,
    SpecificationFilterModel7Spikes specificationFiltersModel7Spikes,
    AttributeFilterModel7Spikes attributeFiltersModel7Spikes,
    ManufacturerFilterModel7Spikes manufacturerFiltersModel7Spikes,
    VendorFilterModel7Spikes vendorFiltersModel7Spikes, CatalogPagingFilteringModel pagingFilteringModel,
    OnSaleFilterModel7Spikes onSaleFilterModel, string queryString, bool shouldNotStartFromFirstPage,
    string keyword, int searchCategoryId, int searchManufacturerId, decimal? priceFrom, decimal? priceTo,
    bool includeSubcategories, bool searchInProductDescriptions, bool advancedSearch, bool isOnSearchPage
  ) {
    var result = _catalog7SpikesController.GetFilteredProducts(
      categoryId, manufacturerId, vendorId, priceRangeFilterModel7Spikes,
      specificationFiltersModel7Spikes, attributeFiltersModel7Spikes,
      manufacturerFiltersModel7Spikes, vendorFiltersModel7Spikes,
      pagingFilteringModel, onSaleFilterModel, queryString,
      shouldNotStartFromFirstPage, keyword, searchCategoryId,
      searchManufacturerId, priceFrom, priceTo, includeSubcategories,
      searchInProductDescriptions, advancedSearch, isOnSearchPage
    );  
    // Add our own stuff to the results and return them
  }
}


Only I cannot compile this. The compiler tells me: 

Assembly 'SevenSpikes.Nop.Plugins.AjaxFilters' with identity 'SevenSpikes.Nop.Plugins.AjaxFilters, Version=3.7.186.18875, Culture=neutral, PublicKeyToken=null' uses 'System.Web.Mvc, Version=65535.65535.65535.65535, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Mvc' with identity 'System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

Eventhough I'm pretty sure SevenSpikes.Nop.Plugins.AjaxFilters was compiled with System.Web.Mvc 5.2.3.0 (at least according to dotPeek), I can't seem to reference it.

I tried this in the web.config:


<dependentAssembly>
  <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
  <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="5.2.3.0"/>
</dependentAssembly>
 

To no avail.

Any thoughts on how I can solve this, or work around it? Or is what I am trying to do totally illegal?
Boyko
8 years ago
#11937 Quote
Avatar
  • Moderator
  • 1570
kev83 wrote:
We created a custom CatalogController which returns a specific custom model. This works fine, until we try to use Nop Ajax Filters, because an incorrect model is returned by getFilteredProducts. 

Any thoughts on how I can solve this, or work around it? Or is what I am trying to do totally illegal?


Hi kev83,

What you are trying to do doesn't seem right to me.
All you need to do is to hook after the GetFilteredProducts method is called and add something to the model, right?
In that case you just need to use an ActionFilter that will modify the model after the action GetFilteredProducts is executed.
Please note that there are templates in the Ajax Filters plugin that expect exactly the same model that the GetFilteredProducts action returns. You can refer to this article about the templates used by the Ajax Filters.

I hope this helps!

p.s: About the error you get: It is strange as the Ajax Filters are built with all the .dlls available in the official version of nopCommerce 3.7.
Regards,
Nop-Templates.com Team
kev83
8 years ago
#11940 Quote
Avatar
  • 5
Ah yes of course, Action filters, why didn't I think of that? I'm going to try it out right away.

Thanks for the tip! 
kev83
8 years ago
#11941 Quote
Avatar
  • 5
Oh, and about the error. It is a strange thing isn't it? I'm trying to build against the 3.5.2 nuget assemblies, but that should be the same thing right?

I can reference pretty much anything in the 7Spikes assembly, ecxept for all things mvc related (i.e. Controllers and the like). Maybe it has something to do with the obfuscation that is applied to the assembly?
kev83
8 years ago
#11942 Quote
Avatar
  • 5
kev83 wrote:
Oh, and about the error. It is a strange thing isn't it? I'm trying to build against the 3.5.2 nuget assemblies, but that should be the same thing right?


I meant 5.2.3.

I need some coffee
Boyko
8 years ago
#11947 Quote
Avatar
  • Moderator
  • 1570
kev83 wrote:
Oh, and about the error. It is a strange thing isn't it? I'm trying to build against the 3.5.2 nuget assemblies, but that should be the same thing right?

I can reference pretty much anything in the 7Spikes assembly, ecxept for all things mvc related (i.e. Controllers and the like). Maybe it has something to do with the obfuscation that is applied to the assembly?


Hi kev83,

I doubt the obfuscation changes the referenced assemblies in the obfuscated .dll.
Please note that your issue is with the build and not during runtime so you don't need to modify the Web.config with any binding redirects (they would work only during runtime).
You should be fine using an ActionFilter so you won't need to do this anyway :)
Regards,
Nop-Templates.com Team
kev83
8 years ago
#11948 Quote
Avatar
  • 5
Yep, that is correct.
I worked out a solution with an ActionFilter and it works fine.

Thank you very much!
khosro
5 years ago
#15098 Quote
Avatar
  • 1
We have the same code that we extend from Catalog7SpikesController but the same error when we want to compile in VS2017.
But surprisingly this code works in VS2013 Update 5.

I do not know what causes that the same code can not be compile in VS2017!!!?

I also try this https://www.nop-templates.com/boards/topic/3053/version-conflict#12914 and add it
to web.config in Nop.Web and also in plugin's web.config(where we extend from Catalog7SpikesController ), but does not work.

Any idea?