I work on a big asp.net entity framework web application with a lot of EDMX (actually 10, later, more than 30). Each EDMX has his own connection string.
When I deploy, my app, I want to change these connection strings. I can replace them with
xdt:Transform="Replace"
But that I need is to replace only a part of the attribut "connectionString".
If my connection string is :
<add name="DemosEntities" connectionString="metadata=res://*/Demos.csdl|res://*/Demos.ssdl|res://*/Demos.msl;provider=Devart.Data.Oracle;provider connection string="User Id=user;Password=password;Home=OraClient11g_home1;Data Source=VDN131DEV15;Persist Security Info=True;ClientId=CLOEE2"" providerName="System.Data.EntityClient" />
I just want to replace VDN131DEV15 with another string on all my connection strings.
Possible with web.config transformation ?
Thank you
There is no Transform operation defined that will allow you to replace a part of the attribute value rather than the whole value.
I think you would need to write a custom build task to apply an xslt to the file in order to do what you want.
Related
I need to make my app to support for multiple languages. So I had created resource files and also binded the strings.
If some strings are coming as dynamic so how do i bind those values in resource files because those values are coming while app is running. Before start I can't hard code those values in resource files.
Thanks for your suggestions.
how do i bind those values in resource files because those values are
coming while app is running.
I don't think you can bind values in resource files dynamically. You have to put strings in your fresh string resource file in advance, while the strings are generated dynamically and we don't know what they are.
If you want to achieve this:
maybe you can find and add a translator in your app and translate the string you generated.(Just my thinking, I haven't tried this way so far)
You could send the string and language type to your server side to get localizable string in different Language. Ask your server side to translate the string for you.
I'm trying to use a "Choice" to direct XML documents based on part of their content. But as I'm new to mule I'm struggeling to understand how to get the xpath expression to parse the incoming message.
As an SSCCE I've set up this flow:
The "when" for each choice is set to
#[xpath('//foo/bar').text] == baz
and
#[xpath('//foo/bar').text] != baz`
respectively.
No Matter what I seem to try; it always gives a response to the client of:
Execution of the expression "xpath('//foo/bar').text] == baz" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: ContentLengthInputStream
Do I need to convert the input into something first? If so then what? Or is there something else I should be doing to make this work?
Edit
Having checked the logs it seems that the error was the same as this. More than one instance of JAXB context. I found two ways to solve this.
One was to refactor all our code to have only one instance of JAXB (not easy and not preferable but it does fix the issue).
The other was to stop using XPATH in EML. Instead I've created a Java transformer which manually uses a Java Document Builder and XPATH objects to extract the information and place it in the registry. This also worked.
Note we couldn't use getPayloadAsString() without hitting "More than one JAXB Context". Don't ask me why mule needs a JAXB context to convert an input stream to a string. So instead we placed a Bytearray to String transformer in the flow:
If anyone has any good way to use xpath in eml when there are more than one JAXB contexts included then feel free to leave an answer
The MULE documentation shows examples like this:
<when expression="#[payload.getPurchaseType() == 'book']">
where the comparison operator and its second operand are all inside the #[...]. Have you tried that? E.g.
<when expression="#[xpath('//foo/bar').text == 'baz']">
I have a Web Forms website on IIS7 and .NET 4.5.1 and I want the http requests to be validated using Microsoft's Request validation. The web.config default values for validateRequest and requestValidationMode are supposed to be "true" and "4.0" respectively and that should be what I want (I tried specifying them just in case).
<pages validateRequest="true">
<httpRuntime requestValidationMode="4.0" />
For some reason, when I input an html tag (tried < script > and < a >) in a form then submitting it, I get the expected Potentially Dangerous request error, but the tag gets saved in the database. Why did it go through? I simply take the textbox's Text value as is and send it to my DB, but I expect the error to stop that from happening.
When I tried setting:
<httpRuntime requestValidationMode="2.0" />
The error was the same, but this time, the tag didn't end up in the database, which is what I want.
I would like to understand why the lesser safe validation mode "2.0" is the only one that actually prevents the request from going through in my case, which doesn't seem to make much sense. There must be something I'm missing, please let me know if I should provide other information.
I have found a solution to my own problem. It would appear that Microsoft's documentation about requestValidationMode states that all values above "4.0" is interpreted as "4.0", but that isn't true. Reading this interesting page, I have found out there's a "4.5" value that is valid and does exactly what I wanted.
Well I am quite new to datapower(IBM Websphere xi50) and i have got struck as to how to route dynamically.Suppose we have configured dynamic backend then a client asks for some service so how to route it .
Is it through XSLT or yhrough certain policy creation I am not getting any clear idea regarding it?
Thanks
Normally you use "var://service/routing-url" and not as Ajitabh answered "dp:url-open".
You can also use the "Set variable" action instead of XSLT.
dp:url-open is used to "fork" a message, not to route it. If you use dp:url-opento route you must also set "skip-backside = 1"!
See sample for XSLT:
<xsl:variable name="destURL" select="concat('http://127.0.0.1:',$Transformer-port,'/', $usrTransformer)" />
<!-- Set backend URL -->
<dp:set-variable name="'var://service/routing-url'" value="$destURL" />
I create an XSLT that looks at the different elements in the incoming message to help determine the destination. I then invoked the DataPower extension method <dp:set-variable('var://service/routing-url') select="yourUrlHere"/>. I put that XSLT into a routing action.
You can do it through XSLT . The steps to do it is as following (logically)
Step 1: Determine the criteria based on which you want routing [it could be URI or any part of message]
Step 2: Use datapower built in function dp:open-url to send traffic to target.
Step 3: Get the response and process it.
There are other ways to do it as well but this is the most straight forward way.
I was wondering if someone has a clue of what is happening here, and could point me in the right direction.
Ok ..lets put the code in context.
I have ajax methods (jquery) like this:
$xmlHttp("/Api/GetWaitingMessages", { count: 20 })
.always(processResult);
($xmlHttp simply wraps a jQuery defered, and some basic $ajax options)
And in our healthmonitoring back-office i see things like this:
Exception information:
Exception type: System.ArgumentException
Exception message: The parameters dictionary contains a null entry for parameter 'count' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult GetWaitingMessages(Int32)' in 'AjaxController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters
Now the thing is, i placed some traces & try/catches (for testing) to make sure that jQuery never calls GetWaitingMessages with an empty or undefined "count", but as far as the healthmonitoring exeptions go: GetWaitingMessages was instantiated and passed null as a parameter. (from what i understand, MVC instantiates methods via reflection)
btw: the error only happens like maybe 1 out of many thousands of requests
The signature of GetWaitingMessages is:
public virtual ActionResult GetWaitingMessages(int count)
{
....
}
So i suppose, mvc shouldn't even hit the method since there should be no signature match..
Does MVC have problems with high traffic websites (ie. multi-threading problems) ?
The site mentioned above is running on a cluster of 5 web-farm servers with Network Load Balancing and IP affinity.
Each server gets around 1500 request/sec at peak times.
The site is using url rewriting to map domains to areas (ie test.com will simply insert /test into the url) since it's a skinable & multilingual white label site.
Some more details on site configuration:
The controller that serves ajax requests is decorated with
[SessionState(SessionStateBehavior.Disabled)]
HttpModules that where considered useless where removed since we need to run: runAllManagedModulesForAllRequests="true" in MVC. I could have set runAllManagedModulesForAllRequests="false", and then try to figure out what to add, in which order, but found it simpler to just remove what i know is not essential.
<remove name="AnonymousIdentification" />
<remove name="Profile" />
<remove name="WindowsAuthentication" />
<remove name="UrlMappingsModule" />
<remove name="FileAuthorization" />
<remove name="RoleManager" />
<remove name="Session" />
<remove name="UrlAuthorization" />
<remove name="ScriptModule-4.0" />
<remove name="FormsAuthentication" />
The following are all activated and configured in the web.config
<pages validateRequest="false" enableEventValidation="false" enableViewStateMac="true" clientIDMode="Static">
and also:
urlCompression
staticContent
caching
outputCache
EDIT : just analyzed my trace logs a bit more. When the error occurs, i see (Content-Length: 8), which corresponds to (count=20). However i do not see any query parameters in the logs. I dumped the HttpInputStream to the logs, and it's completely empty ..but like i just mentioned, the logs also say that Content-Length = 8, so something is very wrong here.
Could IIS (eventually url rewriting) be mixing up it's stuff somewhere along the way ?
-
Any help would be greatly appreciated ..i'm ripping my hair out trying to understand what could possibly be going wrong here.
Thanks, Robert
What type of a request does your xmlHttp issues to a server (GET, POST or something else)?
What is the definition of GetWaitingMessages action method?
It might very well be the case of mismatching accepted verbs or argument names.
I have a feeling that this could be a problem with MVC not being able to bind to your 'count' parameter. By default, it expects the parameter to be named 'id'.
You can try the following:
Modify your GetWaitingMessages action to define it with a parameter called 'id' instead of 'count'
Create a custom model binding as described in the accepted answer to the stackoverflow question at asp.net mvc routing id parameter
Hope this helps
EDIT: Just saw your reply to another answer stating that the action is a POST. In which case, binding may not be an issue.
Just for testing try this to see if there is any problem .
public virtual ActionResult GetWaitingMessages(FormCollection form)
{
var count=Int32.Parse(form["count"]);
....
}
Of course it will throw if the count field isn't set. If it always works correctly then the problem is with routing or model binding.