Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I just wanted to use slimsy in my umbraco instance (Version 7.12.4). But it throws an error, when I want to use @Url.GetCropUrl.
The error says:
Url.GetCropUrl CS1973: 'System.Web.Mvc.UrlHelper' has not such method
Thanks to all who read...
The GetCropUrl() method is an extension method in the Umbraco.Web namespace, so you'll need to include that (if it's not already). So if you are calling it from a view (template) then you'd need to add:
Also, what are the parameters you are passing to the method? If you call it with parameters it doesn't understand then you can get this type of error.
Generally you need to pass it an image of type IPublishedContent as the first parameter. See https://our.umbraco.com/Documentation/Getting-Started/Design/Rendering-Media/
When I include "@using Umbraco.Web", I still get the same error.
When I call it before the @Url like this:
var featureImage = Umbraco.TypedMedia(Convert.ToInt32(ks.foto));
<img class="img-circle lazyload" alt="@ks.betrieb" src="@featureImage.Url"
data-srcset="@Umbraco.Web.Url.GetSrcSetUrls(featureImage, 476, 360)"
data-src="@Umbraco.Web.Url.GetCropUrl(featureImage, 476, 360)"
I got this error:
Umbraco.Web.UmbracoHelper' does not contain a definition of 'Web'
I guess, I missed some web.config References during an older update maybe?
Try calling it like:
@Url.GetCropUrl(featureImage, 476, 360)
@Umbraco.Web.Url.GetCropUrl(featureImage, 476, 360)
This was my initial call. :)
That throws the error with the System.Web.Mvc thing...
Apart from adding the following namespaces...
... did you also create an instance of the UrlHelper? For instance:
UrlHelper urlHelper = new UrlHelper();
string imageUrl = urlHelper.GetCropUrl(mediaItem: imageNode, cropAlias: cropAlias, htmlEncode: false)
More details here:
OK, cool, but you definitely can't use @Umbraco.Web since @Umbraco in this instance would be the UmbracoHelper class rather than the namespace (unfortunately Umbraco calls the property that is exposed in templates @Umbraco, which causes confusion with the namespace of the same name).
So it sounds like you have a config error. What I'd do is download the zip file from https://our.umbraco.com/download/releases/7124 and then compare your web.config with the one in there. In particular, compare the web.config in your /Views/ folder, as this is where MVC references get added.
I just checked it. Except of the slimsy-entry, the web.config in the /views folder are identical. All reference in the main web.config are also identical.
I have no idea anymore...
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted