Ninject Mvc Exception Handling at Controller Constructor - asp.net-mvc

I have a MVC website that works in local but not on remote server.
The erroneous part is the MVC Webapi which uses ninject on controller's constructors.
The post request reaches the webapi while the webapi is working on local computer, and everything is fine.
However, same post request does not reach any method inside same API working on remote computer, and I need to know why.
My guess is that one of the dependencies fail while being injected by ninject.
Saving exception info inside a text file on remote server will do for now. I will implement a thorough solution later on.

Its been a long time, but as i remember , it turned out to be the proxy setting on remote machine.
Multiple api's were talking to eachother via http .
A proxy setting on remote machine , required authorization for these api's to talk to eachother .
Changing the code resolved the problem , otherwise using the proxy with proper authorization was another solution.
Thanks

Related

connect azure functions to local signalr instance

I am currently writing tests for an existing project based on azure functions. The project uses signalr to send live update messages to the clients.
For my tests I am currently using a signalr instance, that is running in the cloud, but I need to replace it by a "local" instance on the system, that is running the tests, so i can be 100% sure, that the signalr message is coming from my test session.
Does anybody have an idea, how to get a signalr-server running in a docker container for my tests (i need a connection string i can provide for the azure functions app)?
I could not find anything online. I am sure I am not the only one, who wants to test if signalr messages are send correctly and i would prefer not to implement the signalr-server myself.
The bindings available in Azure Functions are for the Azure SignalR Service not SignalR itself, so there is no way unfortunately to test this locally.
You could simply instead just create a test Azure SignalR Service instance and use that instead.
I didn't find any way how to achieve this, so i created a repo with a small mock service for the SignalR service. I hope I am allowed to post such stuff here.
My repo and my docker image
Feel free to use / fork it. I am not sure if I will ever find any time to maintain it.

Consuming Web Service with Impersonation: The remote name could not be resolved

I am creating an MVC application with Forms authentication. I have set the application up to authenticate against Active Directory. This works successfully.
I now need my application to consume a Web Api web service within my Domain. When I use Impersonation, the service is never called and object inspection shows the following: The remote name could not be resolved. This is the case for HttpClient, RestSharp and WebClient. If I remove the Impersonation, the code runs successfully (but not as the logged in user).
This throws up a couple of questions:
Can I perform WindowsIdentity Impersonation in a Forms Auth application if the Forms Auth application authenticates against Active Directory?
What is happening to prevent the code from finding my web service when Impersonation is used and how do I resolve this?
Thanks for any help.
Found the answer to my question so posting in case others are stuck with the same issue.
To perform Impersonation when Forms Auth is used you need Protocol Transition with Constrained Delegation. This article is excellent at talking you through the steps required to set this up. Once this is correctly implemented, Impersonation works as expected and the Service URL is correctly resolved.

Consume Secured web service in Asp.Net MVC

I'm working on asp.net mvc
I want to consume secured web service in my project
In previous I can consume unsecured web service (asmx) by calling wsdl to create proxy class ,now
I tried to create proxy class for the service by using wsdl.exe by using the following formula
Wsdl /language:language /protocol:protocol /namespace:myNameSpace /out:filename /username:username /password:password /domain:domain
But I had the following error
Error: There was an error processing 'https:// .asmx?wsdl'.
- There was an error downloading 'https:// .asmx?wsdl'
- Unable to connect to the remote server
- A socket operation was attempted to an unreachable network ??.???.???.??:???
Can you tell me how can I consume secured web service in my project
Yara
I dont know what sort of service you are talking about but I suspect you are Adding it as a Service/Web reference. If thats the case then assuming its called WebService1 and that the security you are talking about it basic authentication then:
WebService1 svc = new WebService1();
svc.AuthenticationHeaderValue = new WebService1.AuthenticationHeader();
svc.AuthenticationHeaderValue.UserName = "username";
svc.AuthenticationHeaderValue.Password = "password";
Try that. As I said I dont have much info on what you are trying to do so its a guess.
First of all it doesn't matter you are in MVC or any other technology.
If you can call https webservice using simple code, it will do wonders for you.
So first try calling simple HTTPS web service, google and play around it.
For learning purpose and to gain more knowledge, check these links
How to call HTTPS web service method from a .net console application?
Calling a https web service (C#)
http://support.microsoft.com/kb/901183

HTTPS website accessing HTTP WCF service

I have deployed an MVC web application on IIS, and it is configured to run over HTTPS.
Further, the website is consuming a WCF service which is deployed on other server (in same network). The WCF service is running over HTTP.
Everything seems working fine, but while accessing the website it is always giving following message on IE 8.
How can we make the site accessible without the below message getting displayed? Also, the solution should not entail any changes at client-level. I need a solution which can be done at site-level.
it seems that you have enabled https and want to consume service vai http. so please change your serviceMetadata
<serviceMetadata httpsGetEnabled="true"/>
to
<serviceMetadata httpGetEnabled="true"/>
If you are calling the WCF service from client script then the error is just warning the user of mixed content mode.
I would suggest you change the binding for the WCF service and call that over ssl. If its important enough for the site to be running over ssl surely this also goes for the wcf service?

WIF SessionAuthenticationModule not executing correctly

I have an odd situation occurring that I am trying to diagnose and would appreciate any advice on where to look.
I have an ASP.NET application using WIF that contains another ASP.NET application as a child in IIS 7.5. This child application contains a REST based web service. Accessing this service directly by pasting a URL into a browser will redirect to an ADFS sign in page. This is how I expect it to work. The odd part is that I have a second environment with the same applications and service deployed, and in this environment I am never redirected to the sign in page.
I have checked that all web.config files are identical, and also checked all IIS settings that I thought might be related. Browsing to web pages on the second environment requires a login, but not when browsing directly to the REST .svc file. I checked all HttpModules and Handler Mappings in IIS. I also enabled tracing of Microsoft.IdentityModel events and on the first environment can see a basic entries for a redirect to the STS. On the second environment I don't see any WIF events. The SessionAuthenticationModule appears to be called when I examine the data flow using IIS failed event tracing, but am not sure why it isn't requiring authentication.
I am familiar with cookie related issues with WIF and made sure that all cookieHandler settings were correct. I also closed browser windows and cleared all cookies to make sure the SessionAuthenticationModule wasn't seeing previous WIF cookies.
If you can think of anything else I should check please let me know.
If you have the same application in two separate environments bound to the same instance of ADFS, the URL's must be different so I am puzzled by the statement "all web.config files are identical"?
Have you tried re-running FedUtil on the application that doesn't work?
Also check AppPool settings.
After a lot of trial and error and carefully examining the applicationHost.config files between the two servers I found out this was caused by a difference in the ordering of HTTP handlers. The ExtensionlessUrl-Integrated-4.0 handler was picking up the request on one server and redirecting to ADFS. On the other server the svc-Integrated-4.0 handler was responding to the request first. You can read more about this behavior here: http://support.microsoft.com/kb/2520479

Resources