سؤال

I am using MVC3, C#, Razor, EF, SQl Server 2008.

I have deployed to Azure using Azure Websites for the main application, SQL Azure for the DB, and Azure cloud services for the DOCX, PDF conversion code. All .NET4.5. I need to use Azure Cloud services as Websites does not support GDI native calls by components.

I need to pass an XHTML document to another HTTP service which is hosted on Azure Cloud services(myrenderer.cloudapp.net). The calling application(myapp.azurewebsites.net) is a MVC ASP.NET application running on Azure Websites. I also use SQL Azure.

Once the XHTML is passed to "myrenderer.cloudapp.net", it is converted into a DOCX or PDF format.

Possible Options:

1) Save the XHTML to SQL Azure DB, call "myrenderer.cloudapp.net" which then retrieves the XHTML from the db for conversion.

2) Pass the XHTML via some call from the MVC Action to "myrenderer.cloudapp.net". Using a querystring would be too retrictive as the XHTML could be 500K. So perhaps some forms based approach might be useful.

3) "myrenderer.cloudapp.net" is not currently setup as a web service, but simply as a straight forward MVC ASP.NET application running as a cloud service, but with the full trust ability to do PDF rendering etc. We might do this in the future, but at the moment we will just use this as a straight forward MVC WebApplicatiion.

What would be a good approach and how. I know how to do 1) but this may have DB Performance issues as one is saving and reloading data from the DB. So I am intrigued as to whether there is a more direct approach by which the HTML to passed direct to "myrenderer.cloudapp.net" from "myapp.azurewebsites.net".

Also there is a security element to this as we would not want anyone being able to access "myrenderer.cloudapp.net" directly. Obviously the caller can stored an authentication token to the DB which is then verfied by the renderer.

URLS are made up, so no pint in trying them.

Thanks in advance.

هل كانت مفيدة؟

المحلول

You can use application/x-www-form-urlencoded POST cross-server request with the authentication token and the content as two url-encoded form values.

Multipart/form-data is another option. (Maybe better for larger files but possibly more complicated)

نصائح أخرى

You can save your rendered PDF or DOCX to BLOB and return just the link to the user. You can save the link or you can assign Shared Access Signature if you want it to be temporary available.

Either you can save it to the blob storage, save its link as file entity and send a message to the web server that it is done.

You can always mix the way you want but saving it to the blob and then just pass around its URL is the best option IMHO.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top