Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve URL for Action from Controller

I am calling a Controller Action from a view, within that controller I need to invoke another Action which I will invoke to save the view to a network location as either HTML or Image.

How do I retrieve the URL to an Action from within a Controller. Please note I need the actual URL, this means RedirectionToAction or View() wont work.

Why? I need to pass in a URL which will contain a call to a View. This view will be used to generate an image or HTML document using the System.Windows.Forms.WebBrowser.

.NET 3.5; C#; MVC 1;

I could do something like this, but its dirty ... well it leaves me with that dirty feeling.

using(Html.BeginForm("Action", "MyWorkflowController", 
new {
   MyId = "bla",
   URLToGenerateImage = Url.Action("GenerateImage", "MyWorkflowController")   
}))
like image 980
Jonathan Avatar asked Mar 06 '26 17:03

Jonathan


1 Answers

I ended up using the MvcContrib.UI.BlockRenderer to convert to View to Html instead of generating the image. I proceeded to save the html string to a file system location.

Here is a link for further information

http://www.brightmix.com/blog/how-to-renderpartial-to-string-in-asp-net-mvc/

like image 96
Jonathan Avatar answered Mar 09 '26 06:03

Jonathan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!