Connecting App for Office with ASP.NET MVC - asp.net-mvc

We created an App for Office from the standard template in VS 2013. We need the app to connect to an MVC project instead of the default web project. So, we replaced the one with an MVC 5 Web API 2 project. If we run the MVC project by itself, it runs well in a browser.
The problem is when we start the App for Office and we expect to see it in a task panel in Word or Excel. VS gives us a popup: “There were deployment errors. Continue?” If we hit “Yes” things work fine but something must be wrong. Nothing specific in the Output window and the only log we get is 1 failed deployment.

I had the same issue. Make sure you select the MVC project in the “Web Project” property of the App for Office. You can access that by selecting your App project in Solution Explorer and hitting F4 to open its Properties window.
Also, make sure you select a valid web page for Source location in the manifest, which I assume you do, because you say “it works” if you click Continue on the error popup.

Related

Visual Studio 2013 not hitting breakpoints

I'm working with an ASP.NET solution in Visual Studio 2013 that fails to hit breakpoints. Visual Studio will successfully hit breakpoints on other solutions, and the breakpoints in this solution previously worked. But at this time they fail to work.
I'm using Visual Studio 2013 Ultimate, Update 4. This is installed on Windows 8.1, 64-bit.
This is an MVC solution that contains 3 projects: BusinessEntities, DataAccessLayer (DAL), and a Web project. Breakpoints in all of these projects fail to work. I even tried a breakpoint inside the Index ActionResult for the home controller, and that still failed to stop at the breakpoint.
In the Visual Studio ribbon, solution configuration is set to Debug. Additionally, Configuration Manager shows that all 3 of my projects have a configuration set to Debug. Restarting IIS, restarting Visual Studio, and rebooting did not fix this problem. Selecting Build > Clean Solution, Build > Rebuild, and then Debug > Start Debugging did not fix it either.
In web.config, debug is set to true in this node:
<system.web>
<compilation debug="true" targetFramework="4.0" />
There are .pdb files in the bin directories of my projects. I verified that they are getting deleted when the solution is cleaned, and recreated when it's rebuilt.
What else do I need to check? I really need to get the breakpoints working in this solution. Thanks.
========
Updates on 12/30/2014 - Below are several things that I tried, following comments from #paul.abbott.wa.us. Several comments I made are deleted and just appended here for clarity.
========
I'm starting the app via VS, and running it under IIS. The version of IIS is 8.5. When exposing the process name (via System.Diagnostics.Process.GetCurrentProcess().ProcessName), it's w3wp.
In IIS, the web application has a site name like "local.mysite", and there is a matching entry in my hosts file. The site uses the DefaultAppPool, which employs the .NET CLR version 4.0 and the Integrated Managed Pipeline Mode. The 3 applications in my solution target .NET Framework 4.
If I switch this back to IIS Express, the debugger starts working. The version of IIS changes to 8.0, and the process name is of course iisexpress. Technically I don't have to run this under IIS on my workstation, but I would prefer to do so. What have I misconfigured or overlooked in IIS that could account for the debugger failing?
Reviewing the project server settings on the Web tab of the properties page, I noticed the dropdown was set to "IIS Express". Upon toggling that to "Local IIS", I was prompted to run VS as Administrator. After doing that, I was able to alter the server to Local IIS, and hit the debugger. I checked in the change, closed VS, launched VS not running as Admin, and loaded the solution. The web project failed to load with the following message: The Web Application Project [MySiteName] is configured to use IIS. Unable to access the IIS metabase. You do not have sufficient privilege to access IIS web sites on your machine.
Eventually some sections of this site will employ Active Directory authentication. So, is the solution that I need to either run the site under IIS Express, or always run VS as Administrator if I wish to run the site under IIS? Thanks.
I found a solution to get past the error message of “The Web Application Project [MyApp] is configured to use IIS. Unable to access the IIS Metabase. You do not have sufficient privilege to access IIS web sites on your machine.” Follow the steps at this post. Error - Unable to access the IIS metabase
After granting my account access to the intetsrv\config folder, the web project properly loaded in Visual Studio without running VS as an administrator.
But now when I launch the site another alert appears: “Unable to start debugging on the web server. IIS does not list a web site that matches the launched URL. Click Help for more information.” Initially I just clicked “Create Virtual Directory” and launched again, but that same alert reappeared.
So I selected the Help button from the alert. That leads to this MSDN page, which proposes about 2 dozen things to check, with about half as many links to other articles. I'm feeling a bit like Alice in Wonderland right now, heading further down the rabbit hole.
2/3/2015 Update: My workaround while running this on the local IIS instance was to run Visual Studio as an Admin. Ultimately, we changed the app to use IIS Express, then later abandoned the app for another solution that a coworker built. That decision had nothing to do with this problem. Thanks everyone for your feedback and ideas.
3/7/2016 Update: At this time I'm unable to replicate this issue, as we no longer have the solution in the state where it was when I worked on it last year. I would be grateful if a moderator could close this question. The options for closing this don't align with my current scenario, but perhaps someone else will find the suggestions below useful if they encounter this scenario. Thank you to everyone who contributed a suggestion.
Make sure that:
Tools -> Options Debugger "Enable Just My Code" is unchecked
You are running the application in the Debug mode, not Release mode
Solution build is up to date.
I met this problem before and solved it after I rebuild the solution package.(right click solution package and run rebuild)
Here is a list of ideas I keep for such an occasion.
Check where your dll is being referenced from and ensure that is the code you're trying to debug.
Check you are in the correct mode when building: Debug/Release as they may put the dlls in different places.
Are you attached to the correct process?
For a website on IIS, is the code you're working on the same as the code running in IIS?
Go to Debug > Windows > Modules and if the relevant dll is there, right click it and load symbols.
If it's not in the list, try running the code anyway. Sometimes even though it says the breakpoint will not be hit, it's only because the dll is not loaded until you enter a scenario that needs it. Try the scenario that depends on the dll, and it may just hit the breakpoint anyway.
Restart your browser. You might have something cached from an older dll.
From my previous experience please consider these :
Check you have put the break point in a right place and you are running the appropriate page or controller
Right-Click on the break point => Location => Check "Allow Source Code to be different from the original version". If you have installed resharper , It's probably help.
If you are calling through Ajax call , Make sure you have not java-script error on the page ( for this IE catch js errors by default)
Some times it's because of not building thoroughly , So cleaning the
solution ( right-click on the solution and choose "clean solution"
item ) then "Rebuild Solution" .
Some times it's because you may have disabled the build option for
some class libraries , So in this situation you need to rebuild those
class-libraries exclusively . (you can find it out by check choosing
"Configuration Manager" item from the "Build" menu)
Hope these help

How can I run an MVC app as a class library?

I've just started working on an MVC 4 app, using Visual Studio 2010, got the app building, but alas am still waiting to get admin rights to my Windows XP box.
...and I don't seem to have any way to run the app in my browser. The startup project is a class library, so I can't run it directly by F5ing, and I lack (probably due to not having admin access) the normal options to set the server configuration in the Debug panel in the project's properties.
So what's the best option for me, anyone? Or is this intractable without admin rights?
EDIT: With MVC, make sure the startup project type is Web Application, not Class Library. I forgot this! If you need to change, see this question. And the problem had nothing to do with not having admin rights.
Right click on the MVC project, Debug->Start New Instance
I am also facing the same issue.
I just modified the csproj file of that project.
I added
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
to the project.csproj file and reload the application and found my solution working at next moment.
With an MVC 2.0 project in VS 2010, the default (and only) output type is ClassLibrary. For me it turned out to be something really stupid. I had accidentally set another class library project in the solution as the StartUp Project. Right click your MVC project in Solution Explorer, and choose "Set as StartUp Project". It should appear bold in the Solution Explorer if it is the designated StartUp Project.

Adding a Web Reference in Visual Studio 11

I have a wsdl file I am trying to add into a Metro application created in the developer preview for Visual Studio 11. This is from a third party API. The sample application provided runs correctly when built with VS11 and the reference is added under Web References in the solution explorer and appears to have the correct listings under the properties page.
I'm trying to use this same reference in my Metro app however there is no option to add a web reference in Visual Studio 11. I've added the wsdl as a service reference, which I've never used before, and after doing that I can not access all the methods I should be able to. It also only has "Folder Name" under its properties.
Does anyone know how I can correctly use this wsdl in Visual Studio 11? Thanks.
Service reference is the correct way to go as long as you're adding the correct URL. Providing this is correct and you are referencing the correct namespace (or specified via "using" in your code), then you should be good.
You can double check this by navigating to the URL via IE and making sure it displays a list of methods for your web service.
Once your "web service" is listed under "References" in your project, you should be able to do a right click and do a "view in object browser" to get detailed information about the your reference (including the namespace it has been placed in).
One final thought, have you tried a brand new project only specifying the reference to your web service.

In Visual Studio 2010, how do you invoke the "View In Browser" feature on an MVC app?

In Visual Studio 2010, you can right-click an aspx page in a web forms app, or on the web forms app itself in the solution explorer, and you get "View in Browser" in your context menu.
In ASP.NET MVC projects, this item doesn't seem to be available in the context menu. The only way I know to run the app is to set the MVC app as a startup project and hit CTRL+F5. But, if there are two MVC apps in the solution, this doesn't really work. How do you accomplish this for mvc apps?
You really can't.
Routes are determined at runtime. There is no way for Visual Studio to know what View its going to use until routes are added, controller actions are hit and the ActionResult is executed.
You can configure your web applications to use IIS so you don't have to hit F5 to run them. The IIS process will automatically start the web site for you. It's such a time saver!
Right click a web project and choose Properties
Go to the Web tab and choose the "Use Local IIS Web server" option.
Enter a url like http://localhost/MyProject
Rebuild.
Navigate your browser to the url you entered.
If you want to debug your website, you can go to Debug > Attach to process..., then attach to w3wp.exe. This will attach to all web apps within your solution. (You might have to select the show processes from all uses option.) If you've just rebuild, you have to reload the site before IIS recycles and the breakpoints turn solid red. (If the breakpoints are ever only outlined in red that means the code running in IIS is an older build than what you are seeing. In rare cases you may have to kill the IIS process, but cleaning and rebuilding usually clears this up for me.)
Note: you'll probably have to go into Window's Programs and Features control panel and enable the IIS features. VS should prompt you if these aren't configured already.

FIrst time writing ASP.NET MVC app- need to tie to SSRS and display reports

Hey everyone.. This is my first time writing an ASP.NET MVC web app, and it's going good. I have no problems there. What I don't have any experience in is SSRS though. Ultimately I want to be able to render reports on my ASP.NET MVC app.
I got the report server installed and running, and it's visible within SQL Server Management Studio.
I created a test report (.rdl) via Business Intelligence Development Studio, and published it to my report server. It's now there, I checked.
My question is how do I tie that into my main application? Do I have to add a reference in my main application to be able to retrieve the report I created? I'm totally lost- I have my main database and my report server both visible within SQL Server Management Studio. That's as far as I got... help???? Thanks in advance..!
Try this: http://geekswithblogs.net/stun/archive/2010/02/26/executing-reporting-services-web-service-from-asp-net-mvc-using-wcf-add-service-reference.aspx
Failing that, if you are new to ASP.NET MVC and you do not specifically require MS Reporting Services (.rdl) created through BI Development Studio, but are satisfied with a standard Visual Studio Report (.rdlc) (This simply means the report may be more or less linked only to the single app. You create these via Visual Studio Project - Right Click -> New Item -> Reporting -> Report) take a look at this link (http://www.danielroot.info/2009/06/how-to-render-reporting-services.html), even though it states how to link Reporting Services, he actually means standard reporting .rdlc files. In essence it publishes simply the output from an .rdlc report as a .pdf and stream it to your user, I have found it to be incredibly simply and a powerful way to quickly publish reports.
Failing that a hybrid of both implementations might allow you to stream your Reporting Service .rdl correctly.
Good luck.

Resources