Assuming you have a field with the image reference, the code should look something like this:
var imgageLink = Util.ReplaceCptInternals(asset["image_field"], addDomain: true, protocolType: ProtocolType.Https);
You shouldn't need to do this in the output handlers (output.aspx) as the DXM publishing engine will take care of this itself. However, if you need this link in some other context, typically a Search G2 handler, then you will need to call this method.
But I am looking something which provide the asset path (image path should access for the public) .
we are creating the JSON for mobile application where they can access the content and assets, but we are facing the deficuties to get the full url which is accessed publicaly. I implemented with whatever you suggested but that is giving me .asp file. hope you understand my concen.
At this point it would be better to open a support case so we can look at your specific implementation. There are multiple factors on generating the path during publish so we need to review how you have implemented your code.
An alternative approach is to load the linked asset and then ask for its link:
var linkedAsset = Asset.Load(asset["ref"]);
// you should always check whether the asset was loaded
// assuming the published assets are available over HTTPS
return linkedAsset.GetLink(addDomain: true, protocolType: ProtocolType.Https);
This code will work in both the output context (good if you are producing JSON resources that will be FTPed to the content delivery environment); as well as the search g2 contexts, (a common way to publish JSON resources indirectly).
NOTE: Asset.GetLink depends on a) your asset having publishing properties set; and b) the workflow stage the requested asset is in.