request.Url in Macro property setter gives null reference exception
Hello,
We have user control in which we have a public property that sets the base url of hyperlinks.
public string DestinationUrl { get { return _destinationUrl; } set { _destinationUrl = Request.Url.GetLeftPart(UriPartial.Authority) + "/" + value; } }
problem is that this property is never set properly. Actually, Whatever reference to Request.Url properties (when referenced from inside a public property) results in null ref exception. This does not happen when the control is used outside umbraco.
Is the Url object beinng reset?
what is the proper way to pass host, authority, path, query properties to a user control through umbraco?
request.Url in Macro property setter gives null reference exception
Hello,
We have user control in which we have a public property that sets the base url of hyperlinks.
problem is that this property is never set properly. Actually, Whatever reference to Request.Url properties (when referenced from inside a public property) results in null ref exception. This does not happen when the control is used outside umbraco.
Is the Url object beinng reset?
what is the proper way to pass host, authority, path, query properties to a user control through umbraco?
Thank you
Dimitris
You can wrap the usercontrol as a macro and expose the public properties as macro parameters.
This could solve your problem.. Pass the querystring values to the macro in a template.
Hi Daniel,
Thanks for your response. I have already created the macro for the control.
this is the macro:
The trace gives me the following exception:
However, when i modify my control property to not reference Request.Url, it works fine.
It seems as if the Request.url object is being referenced before initialization. This does not occur when running the control in a plain asp.net app.
Any thoughts?
Move the Request.Url code to the get and call the property JobPageUrl instead of the variable jobPageUrl from your code
example:
is working on a reply...