0

I have copied a file 1.txt from Container A to Container B.

I am also returning the complete URL of the copied file.

    return new OkObjectResult(targetBlobClient.Uri);

Now, rather than returning I just want to open this file directly in the current browser tab which i used to invoke the function . How can I go about that ? Please guide.

ecstasy
  • 161
  • 1
  • 2
  • 9
  • 1
    So you simply want to open the file and display in the browser, correct? 2 Questions: 1) How are you invoking the function? and 2) What happens currently when you return `OkObjectResult(targetBlobClient.Uri);`? – Gaurav Mantri Jun 26 '20 at 23:44
  • 1)I am publishing the code from VS 2019 ..doing this ... https://copyfiles.azurewebsites.net/api/Function1?filename=sample2.txt&code=*** 2) right now it just prints the URL of copied file. – ecstasy Jun 27 '20 at 00:25
  • So you simply want to open the file and display in the browser, correct? - Yes, Please. – ecstasy Jun 27 '20 at 00:25
  • Typically you would want to consume your function through some code instead of directly invoking it in the browser. Can't you handle it in the client code? So you get the URL as response and then you can redirect to that URL in the client only. – Gaurav Mantri Jun 27 '20 at 00:29
  • if this were a Spring boot or java thing - I would have done it .. c# ..my exposure is hardly 15 hours .. I was hoping there was some inbuilt redirect functionality in c#.. I already have the URL .. just need to open it in browser .. sounds simple .. – ecstasy Jun 27 '20 at 00:35
  • 1
    In normal MVC, there's a redirect action result (https://learn.microsoft.com/en-us/dotnet/api/system.web.mvc.redirectresult?redirectedfrom=MSDN&view=aspnet-mvc-5.2). Please see if you can use that. – Gaurav Mantri Jun 27 '20 at 00:39
  • Gaurav !! .. it worked .. thank you !!!!!!!!!!!!! – ecstasy Jun 27 '20 at 00:56
  • 1
    Awesome! Glad to hear that you’re unblocked . – Gaurav Mantri Jun 27 '20 at 01:05
  • one last help please .. and i will have a good weekend .. https://stackoverflow.com/questions/62604825/generate-sas-token-c-sharp-programmatically – ecstasy Jun 27 '20 at 01:16
  • It’s actually pretty easy. I’ll try to answer soon (currently away from computer). – Gaurav Mantri Jun 27 '20 at 01:26

1 Answers1

1

Credits to Gaurav @ https://stackoverflow.com/users/188096/gaurav-mantri-ais

  string responseURL= targetBlobClient.Uri.ToString();

  return new RedirectResult(responseURL, false);
ecstasy
  • 161
  • 1
  • 2
  • 9