How can i GET and POST global parameter? [closed] - asp.net-mvc-3

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How can i GET and POST GLOBAL parameter?
example:
ViewBag.get = 2;
[HttpGet]/or/[HttpPost]
public ActionResult GetString(string? getnumber)
{
...////
}

You want to have global parameter in controller, but not in actions ?
I am not sure I understand you, but the best way to do that is using session. Something like that:
Set:
Session["Number"] = "2";
Get:
int number = (Session["Number"] != null) ? int.Parse(Session["Number"]) : -1;
I hope that helps, if not, specify your question :)

Related

how to Flatten json null to empty string in golang [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 months ago.
Improve this question
I am searching for go library or work around to flatten the null json value to empty string (""),
from
`{
"foo": {
"jim":null
}
}`
to
map[foo.jim:""]
as of now its being ignored for my use case.
can anybody help me with this.
example code https://go.dev/play/p/9hnMEa6QA2O
you can see that i get the output
map[fee:bar]
but i want
map[foo.jim:"" fee:bar]
after going through the code,
had to check for nil instead of ignoring it in switch case.
default:
if v == nil {
flatMap[newKey] = ""
} else {
flatMap[newKey] = fmt.Sprintf("%v", v)
}

Does spring security JWT implementation deal with alg:none attack? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 3 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Improve this question
JWT implementations might be exposed to different attacks, one of them is the alg:none attack (see more details here).
I'm using spring-security-jwt dependency in my pom.xml file, and was not able to find out whether this implementation deals with the alg:none attack.
Is this attack mitigated by the spring security JWT implementation?
If you are using spring-security-oauth/spring-security-jwt then yes, This attack is mitigated. As per the link you have shared, one way to mitigate this attack is by considering a JWT token with header with "alg":"none" as invalid or not rely on the alg header when selecting the algorithm.
In the source code for spring-security-jwt file JwtHelper in the decode method does not rely on the alg header when selecting the algorithm.
public static Jwt decode(String token) {
int firstPeriod = token.indexOf('.');
int lastPeriod = token.lastIndexOf('.');
if (firstPeriod <= 0 || lastPeriod <= firstPeriod) {
throw new IllegalArgumentException("JWT must have 3 tokens");
}
CharBuffer buffer = CharBuffer.wrap(token, 0, firstPeriod);
// TODO: Use a Reader which supports CharBuffer
JwtHeader header = JwtHeaderHelper.create(buffer.toString());
buffer.limit(lastPeriod).position(firstPeriod + 1);
byte[] claims = b64UrlDecode(buffer);
boolean emptyCrypto = lastPeriod == token.length() - 1;
byte[] crypto;
if (emptyCrypto) {
if (!"none".equals(header.parameters.alg)) {
throw new IllegalArgumentException(
"Signed or encrypted token must have non-empty crypto segment");
}
crypto = new byte[0];
}
else {
buffer.limit(token.length()).position(lastPeriod + 1);
crypto = b64UrlDecode(buffer);
}
return new JwtImpl(header, claims, crypto);
}
There is no document or compilation of vulnerabilities in spring-security-jwt but you can check the issues section under spring-security-jwt and report any vulnerabilities you think which needs to be patched.

Why do I get a "Value of type 'TableViewController' has no member 'place' ''? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am tying to download some data from parse (a string) and I get the error
"Value of type 'TableViewController' has no member 'place' on the line that says :
self.place.append(spotdetail.name!)
I have this as a global var :
var place = [""]
and this is my code in the ViewDidLoad:
let query = PFObject.query()
query!.findObjectsInBackgroundWithBlock ({ (objects, error) in
if let skateparks = objects {
for object in skateparks {
if let spotdetail = object as PFObject! {
self.place.append(spotdetail.name!)
self.tableView.reloadData()
}
}
}
print(place)
})
What can I change to make it work as I don't understand why it doesn't recognize the var place as it is in the same view controller (tableView)
thanks!
Everywhere in closure you should use self keyword for properties:
print(self.place)
As originaluser2 pointed out you are using a global variable so you do not need to user self.place. Also i'm not sure what you are subclassing in PFObject, but your func name is findObjectsInBackgroundWithBlock and you are reloading your table data there. Always keep in mind that you can only interact with the UI on the main thread. This will cause errors, so you can either pass back a callback, or do a GCD call to the main queue and then reload the data there.

Overwriting === method and how to call it [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Is this a proper way to overwite the === method:
def ===(b)
self.venue === b.venue
print " new === !!!!"
end
And how do I call it on objects a and b who (as instances of the same class) both have the variable venue?
I tried puts a.===(b) but it doesn't work. (it says private method called for #<class1:0xsdfsd...>
Yes, it's proper way to overwrite === method.
You can call this method with:
a === b
or
a.===(b)
You have this error probably because you defined === method as private. Define it as a public method (above private keyword) and it should work.
The method should return a true or false, in this case you print something and the return value will always be nil. Try to change the order and use the print first.
Although you can call it using === it is much more common to use the operator in a case-statement or in the grep method.

Creating a loop to generate mouseover functions [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I've got a list of mouseOver functions, which for other pages will be much longer, so I'm looking for a way to generate the mouseOver functions in a loop.
Here's a small list of 5 functions in an example, by putting that in a single loop functions I should be able to understand how to expand it to more.
function mouseOver1()
{
document.pic.src ="img1.jpg"
}
function mouseOver2()
{
document.pic.src ="img2.jpg"
}
function mouseOver3()
{
document.pic.src ="img3.jpg"
}
function mouseOver4()
{
document.pic.src ="img4.jpg"
}
function mouseOver5()
{
document.pic.src ="img5.jpg"
}
Thanks for your help!!
(Moving discussion from comments)
You don't want to create five different methods. You want one method that can handle all of your situations.
function mouseOver(i) {
document.pic.src="img" + i + ".jpg";
}
And where before you would've called it like this:
mouseOver1();
You now call it like this:
mouseOver(1);
Does that make sense?

Resources