Web API 2 project and MVC 5 Website project in same domain - asp.net-mvc-5

Technologies used:
BreezeJS
OData
Web API 2
MVC 5
IDE: Visual Studio 2013
I've been wrestling with the idea of having a Web API project and a separate web site project in a single solution.
My Web API 2 project opens up as: localhost:2020/ExampleProject.API
My MVC 5 WebSite project opens up as: localhost:5050/ExampleProject.WebSite
Now by default web api doesn't allow cross origin policies. So I played around with enabling CORS in my Web API 2, although I was able to get it to work, it only works for the latest browsers; I need the backward compatibility of IE7 to IE9.
So I played around with JSONP. I'm not fond of the lack of support that exists for this. I was able to get it to work for my Web API 2 project, but it doesn't work if I wanted to use BreezeController if using the breezejs web api library. It also doesn't work if I wanted to create an ODataController.
So I'm moving away from the idea of cross origin sharing; though hoping that in the future there will be enough support for jsonp regardless if I use BreezeJS WebAPI helper or ODataControllers.
For now, I have no idea how to put my WebAPI project and my MVC 5 Website under the same domain where I can have:
localhost/ExampleProject.API
localhost/ExampleProject.WebSite
Do I have to make some configuration in my host file? if I want to run my projects from VS2013 would it be able to run both projects under the same domain.. or do I have to keep on manually changing the URL in the browser?

Well, the answer was really really simple.
I know this an old question, it was just that I forgot how to do it since it's been so long since I did this. Searching for the answers on google and on stackoverflow was difficult since the discussions talked about setting up cross origin policies instead of setting up a same origin policy.
I spent the good portion of my time putting everything on IIS.
Created a website and had it point to the physical path where my website csproj and bin folder is located. I gave it a hostname of "dev.example.com" and changed my hostfile for 127.0.0.1 to refer to dev.example.com
Created a Web Application for the website, and set it up for web api 2 project. Everything magically worked after that.
The dumb part was, I could have easily done this in visual studio. I remember in VS2010, this cause many problems, but in 2013, I guess bugs have been fixed and it works now.
I had my WebSite project set up as
localhost:2020/ExampleProject.WebSite (incorrect)
instead of
localhost:2020 (correct)
and created a virtual directory. I do this by right clicking the project, going to properties, under "Web" tab.
So basically, the rule of thumb was to get my website to be my main root domain, and to copy that full domain to any web application I want to add under it.
So: website would be:
localhost:2020
web application:
localhost:2020/ExampleProject.API

Related

Deploying ASP.NET Core 6.0 MVC app to Server doesn't work

I am new to web development, I am learning it on the way as I develop my application.
I have an ASP.NET Core 6 MVC app that basically does this:
Starts with a Login
After login you can view the data
You can manipulate data on the view page
You can view some logs, and acknowledge them
So, my app works just fine when I run it from VS 2022.
I would like to deploy the app, so it can be used within the company. It all works on an internal network.
I have two options for deployment and to host the app from:
Windows Server 2019 (IIS)
Synology NAS
It really doesn't matter for me, but I have been through more than a dozen of tutorials/videos, but could not get it work either way.
I have tried different publishing methods.
I have .NET Core Hosting 7.0.2 and Web Deployment installed on the Windows server.
Basically my published file structure doesn't look like in some of the tutorials.
The furthest I've got is that I can load the page on the Windows Server 2019 machine, it shows the login page, but after I press "Login" it says ".../LoginController" Page not found.
So, after this chaos, can anyone give me some guidance where should I look for the solution? I thought it would be a good idea to use MVC, but now I think it would be much easier with a simple ASP Web app...
Eventually, after I got to the Login page (as I mentioned), I figured out the problem there. I am using cookies, which were set to "secure" in the program, but I was usint http instead of https. As a test, I have set the cookies' "Secure" property to "false", after that it worked.
At least I know where to go next.

Building an App in SharePoint Online

I have a client that wanted an easier way for his team members to build/update pages on their site, their site is heavily customized with a lot of JavaScript. The issues is that when a team member wanted to add a new section to the page they had consult a dev person to hard code in the desired features. So we decided to create customizable web parts of those features making the site more self-serviceable.
When I first started I found some documentation that said to use visual studios to build the web part using sandbox code, upload it to the site and then they would just need to activate it to deploy it on the site. Buuut unbeknownst to me code based sandbox solutions are no longer supported in Sharepoint and therefore the web parts we built could not be deployed. I was then told that I needed to build it as an Add-in, but as I started building the add-ins I found that the customizable field properties (i.e. ability to change background color, text style/color and banner color) that I want are not implementable as a add-ins.
So now I’m back at square one and I don’t know if it’s even possible to build a web part as a add-in or do I need to go a different route?
Any thoughts or links to sources you can provide would be HUGELY appreciated!
Thanks
Terek
In SharePoint 2016 things have changed a lot from the traditional model which was the classic way of building web parts. The way you worked before is called "classic", the new way is called "modern", and the way to get your dev environment is the following (brace yourself, it is a long answer):
1) In SP2016/Online you will need to configure your dev machine with the following environment, installing the following:
NodeJS Long Term Support version
Yeoman (which will be used to create web parts)
GULP (which will play the role of virtual web server)
Once the three components above are installed, you will install the Yeoman SharePoint Generator to create the SharePoint Web Parts, Yeoman simplifies the process of creating things by delivering templates ready to use and making all the configurations standard, you gonna love this guy!
To configure your machine see the following link:
https://dev.office.com/sharepoint/docs/spfx/set-up-your-development-environment
2) In SP2016/SP Online, you will develop for SPFx (SharePoint Framework), Microsoft has made significant efforts to address the changes and help developers to embark on this new journey by publishing training and educational material at GitHub, YouTube, and on its official website (I will add link below), but for the purpose of helping you, please follow this tutorial, it helped me to learn how to develop Modern Web Parts for SP 2016/Online:
https://dev.office.com/sharepoint/docs/spfx/web-parts/get-started/build-a-hello-world-web-part
3) From the tutorial above, you will get a fully functional Modern Web Part that can be deployed to SP2016/Online, you will see the new modern architecture allows you that old experience of "sandboxing" web parts in a faster way without, thus solving your problem of constant updating/refactoring components in a live production environment. This way now allows you to constantly update the code and see the results in real-time , you will be able to see results on your dev environment by calling: https://localhost:4321/temp/workbench.html and at same time on your SP environment. for example: http://portal.company.com/_layouts/workbench.aspx
Links:
YouTube "SharePoint Framework Tutorials" - it is the step by step tutorial video showing the whole process of creating a web part:
https://www.youtube.com/playlist?list=PLR9nK3mnD-OXvSWvS2zglCzz4iplhVrKq
GitHub repository with the full documentation, samples and extras for the SPFx and PnP (this is another story for another time):
https://github.com/SharePoint
I hope it helps you!

Azure Shared Website - Enable PHP in HTML

I have a hosted page on Microsoft Azure Web Sites (Shared) and have verified that PHP is enabled and working but I am not able to call PHP in an .html document. Is there any way to enable this?
Searched high and low on this one, sorry if it is a duplicate.
This drove me nuts too, documentation in so many areas is poor. I had the same problem last week.
Here is the fix:
On the management console of the site, under configure, scroll to Handler Mappings.
In handler mappings, in the first box, type *.html
In the second box type D:\Program Files (x86)\PHP\v5.4\php-cgi.exe
Save, then restart the instance. It will now process PHP inside HTML files.
One small thing, which I didn't realise till after as well. I instantly assumed, 5.5 is the latest and greatest, so why wouldn't I just update to 5.5 and use that engine. You can, and changing the folder structure to read 5.5 works, however the 5.5 build on Azure doesn't have PDO for SQL Server which makes connecting to a native SQL database a nightmare. So 5.4 is the best build IMO until they include that as well.
Hope this helps.
EDIT: Not sure if this is applicable to shared, I am using a small instance, but logic should be the same I would have thought.

How to setup the location element in web.config for Parallel with other Frameworks

I'm reading [https://github.com/ServiceStack/ServiceStack/wiki/Run-servicestack-side-by-side-with-another-web-framework][1] but it doesn't explain enough or give a solution example (or I just don't know of an an example in the SS github site I can see something like this working with ASP.NET MVC and using that location element).
So I don't understand this custom service path from a Solution/Project perspective in the location element.
Here's how my current Solution looks:
Just a bit about the above pic. The MVC project that I created is that one I outlined in orange. I added then the ServiceStack projects I'll need to work with (we want to work with the actual code from SS, not binaries).
So now I'm looking back at the web.config that sits in my MVC proj as you can see in the pic which is open. So this "/api" for example, so what is that referring to? Like Our "Service" that we are gonna expose is in a different project ..you see that at the top, the project Called ServiceInterface.
I'm trying to understand how this works for the location. Location of what and how would I set that up in my solution here just for example?
#CoffeeAddict
sorry, but as a simple ServiceStack user like you, I feel the need to tell you
that it is good to have a lot of questions, but
Here is not private support, please make meaningful questions for all the others.
Don't waste time of mythz. We expect from him to deliver the new ServiceStack version.
If he is successful, all of us we will be too.
P.M
down in the page that you mentioned Run servicestack side by side with another web framework
there is an example of config Example config file for Asp.Net 3.5 in /api.
Maybe it is not appropriate for you, but it is not true, that there is not example.
Also, these questions
Running ServiceStack side by side with MVC
Service Stack on MVC4
the following is from you at Sept 25. It was answered from mythz.
Setting up Web.config to work Side-by-Side with ASP.NET MVC 4
Maybe you are not satisfied of course, but what to do about ? nothing.
check this also
ServiceStack.Host.Mvc / content / README.txt
Here
a user's blog post A mixed ASP.Net MVC 4 and ServiceStack reference project
and his sample project in githup DiffStack

Navigation bar in IBM Connections for Profiles and Files application is hidding

First of all, from the time I deployed IBM Connection navigation bar (this one that lists the applications: home, profiles, blogs and etc.) worked correctly. But some time ago it started to go away(hide) when I switch to Profiles or Files apps. In all the other applications it is working like a charm(visible).
So, possible correlation:
some time ago I've applied CR3 update;
still trying to integrate IBM Connections to WebSphere Portal
(configuration of SSO and all the stuff connected to authorization
from both sides: WP and Connections servers);
Any tips on how to resolve the problem?
After some time I've discovered that the problem was with customization of headers and footers of applications (Profile and Files apps). While integrating to WebSphere Portal there were made changes to footer.jsp and header.jsp with wrong values.
In whole, there are two ways to customize look and feel of IBM Connections:
change look and feel for all applications (jsp files in folder *%connections_install_dir%\data\shared\customization\%app_name%\nav\templates*)
change look and feel for every application\feature (every .war file has nav directory that contains the look and feel information)
Fore more information refer to documentation.

Resources