LucGosso / Gosso.EPiServerAddOn.DownloadIfMissingFileBlob

This EPiServer AddOn provider copies (when page loads) the file blobs from production to your local environment, or to your staging/test environment
4 stars 2 forks source link

UrlResolverUrl fix #9

Closed Norrj closed 5 years ago

Norrj commented 5 years ago

We had some problem when we not defined the UrlResolverUrl in our webconfig, so I found that the defaultUrl was set to modules/Gosso.EPiServerAddOn.DownloadIfMissingFileBlob/{UrlResolver} and in commit https://github.com/LucGosso/Gosso.EPiServerAddOn.DownloadIfMissingFileBlob/commit/c2c1dac81ce2453eaaedfccf78c36fca5b590b5b#commitcomment-32742987 the replace of {UrlResolver} were removed.

So when building the url we got "Https://mysite.se/modules/Gosso.EPiServerAddOn.DownloadIfMissingFileBlob/{UrlResolver}?[guid].

After seeing this we added UrlResolverUrl to our configs but still could not get it to work. After changing the url to lower case it magically started to work for us.

LucGosso commented 5 years ago

The {UrlResolver} is very important when registering the route (in init.cs). It has something to do with webforms compat, i don't remember (have to look in history books) therefore i do not want to commit this PR. You may register a new route yourself and point it to UrlResolverHelper() with lowercase.

Though i agree, it is best practice to use lowercase. That i could change to next version.

LucGosso commented 5 years ago

You may also put "urlresolver.ashx" anywhere on your prodserver and change UrlResolverUrl="path/to/urlresolver.ashx".

Norrj commented 5 years ago

The {UrlResolver} is very important when registering the route (in init.cs).

You are absolutely right. I made some more digging and found in commit: 3ed9695fa24fc2edba5ac43eca5f5aab6087951a , named "MVC compat fix", that you handled the UrlResolverUrl in the Initialize method.

Then later in this commit. c2c1dac81ce2453eaaedfccf78c36fca5b590b5b where you add logging, you are romoving it again.

It lookes like, based on the naming of the commit, that removing the replace was a mistake. I have been testing this pr by removing the UrlResolverUrl from my web.config. Before the change in this PR it did not work, now it does. :)

LucGosso commented 5 years ago

Thanks for your effort! You have a point. I will test some more.

It has worked for others though and me, but i get why it may not work for all.

Norrj commented 5 years ago

God morning, I just took a look at the code this morning again (fresh eyes) and understood what you mean. I had been so focused on DownloadIfMissingFileProvider that I diden't look in Init (long time ago I registered routes, so a bit rusty :P)

It is strange, I have the same issue here though. it only work if I have the entire defaultUrl in lowercase :)

So you are absolutely correct in that we should not do a replace in the DefaultUrl 👍

I'll go ahead and close this PR, I will create one with my code with lowercase for defaulturl that you can just take a look at the difference. I tried to find some information about lowercase url in routes or something, but I wonder if this can just be a setting on our server?

LucGosso commented 5 years ago

yes probably a setting on your server. For next release i will do it lower case i think anyhow.