I have a ASP.NET Web APi project that uses an AngularJS as the front end. It is called "MyApiApp".
http://localhost/MyApiApp
I would like to move this project under another project that is an ASP.NET web forms website. It is called "MyWebForms" app.
http://localhost/MyWebFormsApp
My goal is to move the "MyApiApp" under the Web Forms app and access the "MyApiApp" as
http://localhost/MyWebFormsApp/MyApiApp
Is it possible to have an ASP.NET Web API hosted under an ASP.NET Web Forms project? I would like to be able to do this in Visual Studio where I could run that Web Forms application but have access to the "MyApiApp" app via the above URL.
Yes. You should be able to set it up as a virtual folder in IIS underneath the main website.
In the case of the VS Project, the built in web server doesn't support virtual folders, you'd have to set it up to run through actual IIS.
You should be able to have the WebAPI Controller as part of the main web forms project though.
Related
I have an asp.net web application and a universal windows platform application running on my laptop with a web cam.
I want to access the web cam from my asp.net web application.
If you want to access access camera from a web hosted UWP app, you can refer to Create your Hosted Web App. And you probably need to enable the WebCam and MicroPhone capabilities in UWP App's manifest file in some scenario.
If you want to make your web application can directly call the camera device without a UWP app, you can use some jQuery webcam plugin. For example, you can try this one. But this can not be used from your UWP app.
In this case, if you want to access web cam both from hosted uwp app and your web app, you need to implement two procedures in your web app, one for hosted UWP app using WinRT API to call the camera, the other one for web app only.
Hi I have a website made it in ASP.NET, I don't have the code to create the web role instance, but I have already hosted my application in a virtual machine. Does anybodoy knows if can I host this application in a windows azure instance? Thanks.
If your ASP.NET project is a web site and not a web app, its a little complicated. If its a web app, converting it into a Web Role is simply a matter of adding a cloud service project to the solution and then right-click on the "roles" branch in that project and "add existing web role in solution" option. You can then select your ASP.NET web app and poof its a web role. All that remains is to add any customizations you want (not required) to allow the web app to properly take advantage of the Windows Azure environment.
If its a web site, you'll first need to convert it into a web app. This really isn't any different then converting it to a web role. Which is just a matter of creating a new empty project and copying your old project's content files into the new project.
I've written an ASP.NET website along with a companion WinForms desktop application, which is used to maintain the site.
The desktop application needs to create a user. However, this is awkward because I would need to ensure all the membership settings are exactly the same as they are in my website's web.config file.
It would be easier if my desktop application could "call into" the website somehow and tell it to create a user. It seems like a web service would be a good option for this. However, Visual Studio doesn't have an option to add an ASMX file. And if I create a separate, web service application, then that application would have the same problem my desktop application has.
Is there a way to add a single web service to an existing ASP.NET application? Any links? Thanks.
Visual Studio doesn't have an option to add an ASMX file
In the Web application project, or the WinForms project? I assume you mean that you cannot add a Web Reference from within your WinForms project; adding an .asmx file to the WinForms project is not necessary. The Web application project should have the .asmx file, which is called by the WinForms project using a web reference.
In the WinForms project you can consume a web service by right-clicking References in the Solution Explorer, then choosing Add Service Reference... (in Visual Studio 2008; other versions may say Add Web Reference...). Then just enter the web address (which may be local in your case, e.g. localhost/foo.asmx) of the web service (.asmx).
See the section "To call an XML Web service synchronously" in this MSDN article: Calling XML Web Services from Windows Forms.
As an alternative, this MS KB article shows how to use the WSDL tool to generate a class that can consume a *.asmx URL. (The article uses VB, but you can switch the parameter to CS to generate C#.)
Update
To add an .asmx file to your Web project, right-click the project in Visual Studio, select Add -> New Item... -> Web Service. If there is not a "Web Service" item any where in the template browser dialog that comes up, then you are missing the template or you're looking in the wrong place.
I stumbled upon this project ASP.NET WebProfile Generator
Why would I need proxy class to access profile?
Because ASP.NET only supports Profiles out-of-the-box with the Web Site option. If you are using a Web Application Project (WAP), then you have to roll your own.
The problem stems from the fact that the Web Application Project does not have the Profile object automatically added to each page as with the Web Site project, so we cannot get strongly-typed programmatic access to the profile properties defined in our web.config file.
Good news is that it's very doable:
ASP.NET: Web Site versus Web Application Project
How to add a Login, Roles and Profile system to an ASP.NET 2.0 app in only 24 lines of code
Web Profile Builder
Web Profile Builder for Web Application Projects
Writing a custom ASP.NET Profile class
ASP.NET Profiles in Web Application Projects
If you create an ASP.NET web file project you have direct access to the Profile information in the web.config file. If you convert that to a Web App and have been using ProfileCommon etc. then you have to jump through a whole bunch of hoops to get your web app to work.
Why wasn't the Profile provider built into the ASP.NET web app projects like it was with the web file projects?
Actually, Microsoft does have a solution for this known issue.
It's the "Web Profiler Builder". I used it for my Web App and it works great.
http://code.msdn.microsoft.com/WebProfileBuilder/Release/ProjectReleases.aspx?ReleaseId=980
The profile provider uses the ASP.NET Build Provider system, which doesn't work with Web Application Projects.
Adding a customized BuildProvider
class to the Web.config file works in
an ASP.NET Web site but does not work
in an ASP.NET Web application project.
In a Web application project, the code
that is generated by the BuildProvider
class cannot be included in the
application.
source: MSDN Build Provider documentation