I've two separate tables to log user activity and errors in asp.net web Api.
Here's my Activity Log table:
To store the Log information in the table, Here's the Nlog.config setting.
<target name="database" xsi:type="Database" keepConnection="true" useTransactions="true"
dbProvider="System.Data.SqlClient" commandType="Text"
connectionString="data source=XXXXX;initial catalog=XXXXX;integrated security=false;persist security info=True;User ID=XXXXX;Password=XXXXX"
commandText="INSERT INTO [dbo].[ActivityLog]([PageName],[MethodName],[IPAddress],[RequestedUrl],[IsAuthenticated],[UserName],[Date]) VALUES(#PageName,#MethodName,#IPAddress,#RequestedUrl,#IsAuthenticated,#UserName,#Date)">
<parameter name="#PageName" layout="" />
<parameter name="#MethodName" layout="" />
<parameter name="#IPAddress" layout=""/>
<parameter name="#RequestedUrl" layout="${aspnet-request:serverVariable=HTTP_URL}"/>
<parameter name="#IsAuthenticated" layout="${aspnet-user-identity}:isAuthenticated"/>
<parameter name="#UserName" layout="${aspnet-user-identity}"/>
<parameter name="#Date" layout="${date:s}"/>
</target>
For the Page Name parameter I need the Web API Controller Name, and for Method Name parameter I need the action Method of the Controller that is called.
Also I need to know whether the user is authenticated or not.
Now Kindly let me know the settings defined in the Nlog config file are correct or not and also how to pass values to the other parameters.
All possible layout renderers could be found here.
You could use the following renderers:
Web API Controller Name: ${aspnet-MVC-Controller}
Method Name: you could use the ${callsite} or ${aspnet-mvc-action}
isAuthenticated: ${identity:isAuthenticated}
PS:
All parameters to the database target are string parameters
Related
I trying host my project, but when I run svc file then i get exception.
Exception data: System.InvalidOperationException: The convention requires the use of Session, but the "BasicHttpBinding" binding is not supported or is not configured correctly.
What could be the problem?
I tried changing the web.config file but I don't know what the problem is
You can change your binding mode from BasicHttpBinding to WsHttpBinding. Since the default binding method for HTTP is BasicHttpBinding, you can modify it in the <System.ServiceModel>:
<protocolMapping>
<add scheme="http" binding="wsHttpBinding" bindingConfiguration="WsHttpSession"/>
</protocolMapping>
This allows you to modify the binding.
The not-very-patient DBA in my group has given me a string similar to the following as my LDAP connection string -
jdbc:oracle:thin:#ldap:/oidAAA.ourdomain.com:4444/foo,cn=OracleContext,dc=bardb
And according to the Oracle Documentation:
For OID, all ldap.ora parameters must be set with valid values to
complete configuration.
I have found a list of "all ldap.ora parameters" but I've yet to deduce which parts of the above connection string map to which parameters.
Thanks to some help from the DBA, I've been able to determine the following:
<LDAPSettings>
<LDAPSetting name="DIRECTORY_SERVERS" value="oidAAA.ourdomain.com:4444" />
<LDAPSetting name="DIRECTORY_SERVER_TYPE" value="OID" />
<LDAPSetting name="DEFAULT_ADMIN_CONTEXT" value="bardb" />
</LDAPSettings>
The question I have now is how to actually USE this. Assuming my database is "foo" how do I use ODP.NET to resolve this?
Any assistance would be greatly appreciated.
I assume you have enabled the config parsing
<configuration>
<configSections>
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=[...], Culture=neutral, PublicKeyToken=[...]"/>
[...]
Now you need to specify your connection string
<configuration>
<connectionStrings>
<add name="myFooConnection" providerName="Oracle.ManagedDataAccess.Client" connectionString="User Id=[...];Password=[...];Data Source=foo"/>
Note the Data Source=foo part. It uses the configured TNS, LDAP etc. to resolve the connection.
You can reference the connection by name myFooConnection with compatible ASP.Net controls or directly pass the connection string to an Oracle.ManagedDataAccess.Client.OracleConnection
VB.Net:
Dim connectionString As String = System.Configuration.ConfigurationManager.ConnectionStrings("myFooConnection").ConnectionString
Dim connection As New Oracle.ManagedDataAccess.Client.OracleConnection(connectionString)
I am developing a webapp with an embedded webservice with Axis2 using Maven.
The service implementation is a POJO with RPC-style interaction, the target appserver is Tomcat running the Axis2 servlet.
The "Hello world" works but now I need to configure some global axis2 settings in the axis2.xml file (placed under WEB-INF/conf).
Please provide or point to a simple configuration for axis2.xml for this common environment.
The default taken from the binary distribution has too many features activated (hotdeploy?) and also causes this problem:
<soapenv:Reason>
<soapenv:Text xml:lang="en-US">
The ServiceClass object does not implement the required method
in the following form: OMElement ping(OMElement e)
</soapenv:Text>
</soapenv:Reason>
As a reference: http://axis.apache.org/axis2/java/core/docs/servlet-transport.html says to configure the servlet transport in this way, but it does not solve the issue.
<transportReceiver name="http" class="org.apache.axis2.transport.http.AxisServletListener"/>
Apparently the problem is that the default axis2.xml sets raw xml messageReceivers, instead of the RPC ones.
Try to add this to the services.xml for the developed service, should fix the problem.
<messageReceivers>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</messageReceivers>
"Solution that worked for me was adding the operation tag in the service.xml against the Java Service method name:
<operation name="sayHello" >
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
<parameter name="ServiceClass" locked="false">com.learning.webservices.pojo.HelloService</parameter>
i am new to windows 8 metro application development , please let me help out in figuring out this issuse.
i want to consume web services in my metro application but the service reference url is dynamic.
i my app , the user will be given a provision to specify the url in a textbox , so i need to connect to that web service , that means the service reference url will be changing.
Till now i am connecting to web service in a traditional way like , giving a specific service reference by adding service reference and creating an instance and using that instance to call all the methods inside that web service .
but,
1) how should i consume web services if the service reference url is changing.
2)Access individual service methods inside that service (call that methods by passing some parameters as inputs).
Thanks in advance.
If you have the same service with different locations simply add it with "Add Service Reference..." and add the specified URL in the service client constructor:
var svc = new DataServiceClient("BasicHttpBinding_DataService",
"http://url.com/DataService.svc");
BasicHttpBinding_DataService is your (generated) binding name from the client config (automatically generated when doing "Add new Web Reference..."):
Example ServiceReferences.ClientConfig
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_DataService" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="TransportWithMessageCredential" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://localhost:44300/Services/DataService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_DataService"
contract="DataService.DataService" name="BasicHttpBinding_DataService" />
</client>
</system.serviceModel>
</configuration>
The code above can be used to change the address (e.g. https://localhost:44300/Services/DataService.svc) to one generated at runtime...
And have a look at this: http://blog.rsuter.com/?p=281
I have an ASP.NET web project and a membership provider configured via my web.config. Its fully working so no problem there.
We have an older system with a lot of users and I would therefor like to create a class library that can create users in this ASP.NET project but since its a class library it cannot have its own app.config-file.
is it possible to set all this information via code somehow?
<membership defaultProvider="ShidMembershipProvider">
<providers>
<clear/>
<add name="ShidMembershipProvider" type="SundaHus.AspNet.Membership.ShidMembershipProvider" connectionStringName="ShidConnectionString" enablePasswordRetrieval="true" enablePasswordReset="true" requiersQuestionAndAnswer="true" applicationName="ECB3-development" minRequiredPasswordLength="5"/>
</providers>
</membership>
You have a custom membership provider it looks like? This connects to your own custom database? You should be able to just point to that database for your code. Or, if you just inherit the functionality from the base class, you can also try overriding the Initialize method, look for the connection string, and change the value to something else.