Any modification necessary to web api project web.config when web api project is created as a web application under an asp.net web site? - asp.net

I have an asp.net web site which runs on port 443 which is https. I also have a asp.net web api which also needs to run on port 443. Because of that, I decided to create a new web application under asp.net web site. I also created a new application pool for that. The problem is that when I try to run web api project, I keep getting configuration file errors. For example it says Default Connection is already added since asp.net web site web.config adds Default Connection already before web api project does. Are there any special steps to take in order to make this work?

Related

Hosted Blazor WebAssembly with Admin Pages

I have a Blazor WebAssembly application that is being hosted by an ASP.NET Core backend. In addition to serving the Blazor application, the backend also has a few API endpoints used within the Blazor application along with some pages that serve as an admin dashboard.
During local development, all was working correctly and I could navigate from inside the Blazor application to an admin page and back again. Once I published this setup to a development server the Blazor app seems to be blocking any requests to the admin pages. I know this is possible as that is what the built-in identity system does. Whenever I try to access my /admin page the Blazor application stays open and shows the message: Sorry, there's nothing at this address.
What do I need to adjust to have things operate as they do locally?
After further research, I discovered that my problem is because of how the service-worker.published.js handles requests. I have this application setup using the PWA feature for better offline support.
For more information on this subject check out the documentation Microsoft provides here: Support server-rendered pages

Routing fails when api is created as a web application under another site

I developed a rest api using ASP.net web api. When I deploy this rest api on iis, I need to create it as a web application under an asp.net web site. When I was deploying the rest api as a new web site in iis, then things worked fine. I was using the following Route api/{controller}/{id}.
When I created the rest api as a web application underneath asp.net web site project, I named the web application as api. I can't access the api methods now. Can someone point what I do wrong?
WebApi is based on global.asax and web.config configurations and you can't have 2 of these files inside in the same application. In the scenario you described, it sounds like you need to create a "Virtual Directory" in IIS for the second application instead of making just a "Sub Folder".
The Virtual Directory will allow you to declare a new web.config and global.asax where you set the new routings and configurations method for your second application.
For a full walkthrough on how you can perform this please refer to this site:
http://msdn.microsoft.com/en-us/library/vstudio/bb763173(v=vs.100).aspx

Asp.net url routing traps asmx web service call

I have an Asp.Net 4.0 Web Forms project that uses url routing for user friendly urls, i.e hiding aspx-pages behind clear text urls.
In this project we have an asmx web service that serves some jQuery controls on the pages. Everything has worked fine so far on development machines and the internal testing site but now when we installed the project on a production site the asmx calls are trapped by the routing code.
We have a catch all route that is added last that shows the Not found -page.
When I open the web service on the server (http://localhost/service.asmx?op=MyWebMethod), enter some values and click Invoke I get the Not found page. The url that Invoke opens is http://localhost/service.asmx/MyWebMethod so it's all quite logical (service.asmx looks like a directory) but I don't understand how this can work on all other installations of the same project.
The production server is Windows 2008 Server R2 Standard, the project is Asp.net 4.0 and I haven't registered any StopRoutingHandler for asmx-files.
The web.config files are identical between the internal testing site and the production site and the machine.config -files haven't been touched to my knowledge.
routes.Add(new Route("{resource}.asmx/{*pathInfo}", new StopRoutingHandler()));

Error attempting to access a web service (hosted locally or externally), can't resolve host name

I'm stumped. I've got an asp.net mvc app being hosted on a shared hosting provider. The configuration of their system leaves a little to be desired, but it's cheap (getting what I pay for I suppose...)
The problem is this: The application is hosted at the root level of the hosting account. I have a virtual directory established underneath the root that is running a .net 2.0 web app along with a web service. I can access the web service directly via the domain/subdirectory url. The main web app (at the root level) needs access to the web service in the virtual (subdirectory). Locally in development, I can run the app against the web service out on the hosting server and it runs just fine. When I push the web app up to the root of the hosting service, I get "The remote name could not be resolved: ".
At first I thought the error was related to the DNS settings of the primary domain since both the web app and web service technically live at the same domain. As part of just trying to get something working, I reverted the web app to reference an older version of the web service on a different server (different host altogether). Again, it works fine locally. When I push the updated web app, I got the same error, but noticed the host name referenced is that of the external domain. Of course, I can access the web service via the browser just fine.
Sorry if this doesn't make total sense... it's late and I'm beat from looking at this for the last few hours. Any help would be greatly appreciated.
EDIT
So the web app simply has a Web Reference to the web service (I could probably just restructure the app avoiding the web service altogether, but time is of the essence [for now]). Since I got stuck last night, I pointed the web reference back to an old server but the issue remains. Right now the url the web reference points to is http://road34.hi-fisoftware.com/webservices/giigsterservice.asmx.
If the server has a firewall then and an external ip and different internal ip then probably you will not be able to access the webservice with the domain name. you will need to access it as internal url or as relative url.

Publishing an ASP.net Webservice

I have a solution with a number of projects in..
One of these projects is a web application, another is a web service.
The web app references the web service, and uses the methods in there.
In production, the web application will be hosted on one server, while the xml web service will be on another.
My question is, how do i deploy this?
I've "published" the application to the correct server, however what do i do with the xml web service? and how can i configure my web application to point to the other server, rather than try and use localhost....
You generally won't leave your web service proxy classes with their default URL in production code. You can configure the production web service url in your web.config class and then have something like
MyWebService svc = new MyWebService();
svc.Url = WebConfigurationManager.AppSettings["MyWebService"];
Something along those lines should get you what you need.
When you add the proxy to you web application, you can set it to be dynamic url. This will create a config file entry that can be set during your deployment. Click on the Web Reference in the Solution Explorer, change the URL Behavior from Static to Dynamic from properties. An app.config file will be created with a key.

Resources