locked
Automatically View in Browser RRS feed

  • Question

  • Using a VS add-in, I will be creating a .aspx file within the active project. Is there a way to automatically view the created .aspx file in the browser via the add-in itself?

    Thanks!

    Sunday, May 19, 2013 3:25 AM

Answers

  • There are several approaches, depending on your needs:

    1) You can select programmatically the .aspx page in the Solution Explorer and then call DTE.ExecuteCommand("File.ViewinBrowser")

    2) You can compose the full URL of the .aspx page using:

    - The base URL of the web site project: Project.Properties.Item("BrowseURL").Value

    or web application project: Project.Properties.Item("WebApplication.BrowseURL").Value

    - The relative URL of the .aspx file: ProjectItem.Properties.Item("RelativeURL").Value


    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/


    Monday, May 20, 2013 7:23 PM

All replies

  • Hi,

    I guess that you want to open a browser via an add-in. As I know, we can create a toolwindow like the object browser.

    About how to create a toolwindow, please view:

    http://msdn.microsoft.com/en-us/library/envdte80.windows2.createtoolwindow2.aspx

    Best regards,


    Ego [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    • Edited by Ego Jiang Monday, May 20, 2013 8:02 AM
    Monday, May 20, 2013 8:01 AM
  • Hi,

    See if this helps:

    HOWTO: Open the Web Browser and navigate to a page from a Visual Studio add-in or macro

    http://www.mztools.com/articles/2008/MZ2008012.aspx


    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/

    Monday, May 20, 2013 9:12 AM
  • Thank you very much for replying.

    However, I require to open a .aspx web page within a VS project in the browser. It should act as a shortcut to the "View in Browser..." feature available in VS web projects.


    Monday, May 20, 2013 2:37 PM
  • Thank you Carlos

    The link you provided answered my issue to a great extent in that I am now able to open up a web browser given a url.

    I still need to find a way of browsing a .aspx file in a VS website project. Here I do not have a url as such but the name of a web page.

    Monday, May 20, 2013 2:43 PM
  • There are several approaches, depending on your needs:

    1) You can select programmatically the .aspx page in the Solution Explorer and then call DTE.ExecuteCommand("File.ViewinBrowser")

    2) You can compose the full URL of the .aspx page using:

    - The base URL of the web site project: Project.Properties.Item("BrowseURL").Value

    or web application project: Project.Properties.Item("WebApplication.BrowseURL").Value

    - The relative URL of the .aspx file: ProjectItem.Properties.Item("RelativeURL").Value


    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/


    Monday, May 20, 2013 7:23 PM
  • This was what I was looking for. Thank you once again Carlos.
    Tuesday, May 21, 2013 3:16 PM