MVC 3 generation URLs [closed] - c#

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
In my application i want to be able to send an email to a user. In Email i want to have an URL- link to an application page, but url have to be generic (because i need to be able to get some data from DB, depend on generic part of email).
For example :
I send email to user with URL : www.testpage.com/recetpassword/Qb12T
On load of the page i need to get data from DB and for example say Welcome UserName(which i get from DB).
Bad example, but it explains what i need

Looks like you need to add a new static route in your Global.asax.cs file:
routes.MapRoute(
"reset_password", // Route name
"resetpassword/{id}",
new { controller = "SomeController",
action = "ChangePassword",
id = UrlParameter.Optional
}
);
Then in your Controller:
public class SomeController : Controller {
[HttpGet]
public ActionResult ChangePassword(string id){
/* change password logic/domain calls */
return View(/* some model */);
}
}

Related

How to add a wiki page through ItemAdded event receiver coding on the addition of a new item in a list? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I have a list named 'List1' in which I have 'title ' and 'WikiLink' columns. I want to add a wiki page on the addition of a new item using ItemAdded event receiver code and update the link on 'WikiLink' column. Please help me out in this. I have been stuck on this for quite a while.
Thanks.
To create wiki page, you will have to add new item into one of the libraries that accepts wiki pages. Typically it's Site Pages, with code more less like this:
var l = (SPDocumentLibrary) SPContext.Current.Web.Lists["Site Pages"];
var folder = l.RootFolder;
var f = folder.Files.Add(string.Format("{0}/{1}", folder.ServerRelativeUrl.TrimEnd("/"), "MyWiki.aspx"), SPTemplateFileType.StandardPage);
//Site Absolute url + Site-relative Url, more info on MSDN.
var url = string.Format("{0}/{1}", SPContext.Current.Site.Url.TrimEnd("/"), f.Url);

how to get the value from address bar entered by client? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I don't know how to put the title but i will try to explain it the requirement here.
Normally user entered an URL in address bar in browser, for example www.example.com, then click a link and redirect to another page www.example.com/test.aspx. Alternatively, user also can just enter/type www.example.com/test.aspx from address bar if they know the full path.
So, i required to write a code where user can type an URL in address bar, for example www.example.com/test.aspx?usr="www.test.com". (note: with addition usr="www.test.com")
The "usr="www.test.com" after www.example.com/test.aspx? contain a value that stored in database.
So, when the user type www.example.com/test.aspx?usr="www.test.com" it will search the database for matching www.test.com and do some process if found.
How can i achieve this.
You have to use Request.QueryString to get value any param passed to the page.
The result, stored in a page variable, can be used to retrieve the needed data.
string usr = Request.QueryString["usr"];
You can get the values in url after ? from HttpContext using
string url = HttpContext.Current.Request["usr"];
If the value is being passed through in the query string (the part after the '?'), you can just check for it using the Request object.
C#
string url = HttpContext.Current.Request["usr"];
// Then perform your search based on the value in URL.
Note: You can also use string url = HttpContext.Current.Request.QueryString["usr"]; if you want to ensure that your value of usr is only from the query string and not a POST or COOKIE. See here for further info.

How to call a model from with in a class? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have a model witch is holding different values in my website and i am currently trying to retrieve the value token.
I call my model in the following way:
HoldToken t = new HoldToken();
string token = t.Token;
This is how the model looks
namespace MvcResComm.Models
{
public class HoldToken
{
public string Token { get; set; }
}
}
I am always receiving null as my returned token. I think this is because i am using the new keyword.
How can i instantiate the model HoldToken with out newing it?
Most likely, you're using a constructor-less class and an automatic property.
I'd guess that you're not setting the HoldToken automatic property, which is why you're getting the null.
Add a new parameterless constructor and make sure the Token member is initialised in some way.
public HoldToken()
{
// Set value of token here
// Guessing at how you'd instantiate it.
Token = new Token();
}

Scoop.it API access in C# [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I'm trying to access the Scoop.it API via C# to retrieve posts in topics. It's pretty much straight forward, in PHP, how are objects managed in C# and how to you access the properties?
Here's the php code which i'd like to get a C# equivalent of:
$topic = $scoop->topic(24001);
foreach($topic->curatedPosts as $post)
{
echo $post->title;
}
I couldn't find an API reference for Scoop.it in C#, but I would imagine that they conform to the naming standards in C#.
So the PHP code converted to C# would looke like this:
var topic = scoop.Topic(24001);
foreach(var post in topic.CuratedPosts)
{
Console.WriteLine(post.Title);
}
However echo in PHP prints something out to the web-page, so I would imagine that you want to replace Console.WriteLine with Response.Write.
If you have a class that looks like this, where Name is a property:
class Topic
{
public string Name { get; set; }
}
Then you would create an instance of Topic like this:
var topic = new Topic();
Now you can access the property Name like this: topic.Name

From Flash to Asp.net [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I have a flash file, but I haven't got the source codes.
How can I get values from it?
For example if it was a html form, I can get the posted values like below:
Request.Form("myValue")
But it doesn't work. How can I get the posted values?
Thanks.
In HTML, this code:
Request.Form("myValue")
Is not accessing the HTML source code; it's accessing the data sent in an HTTP form post. In HTML, the input names happen to dictate which form variables are sent.
ActionScript (the Flash programming language) can do a post just like HTML. Here's some sample code:
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest("yourpage.aspx");
request.method = URLRequestMethod.POST;
var variables:URLVariables = new URLVariables();
variables.myValue = "foo";
loader.addEventListener(Event.COMPLETE, handleCompletion);
loader.load(request);
private function handleCompletion(e : Event):void {
// Do things after the post completes
}
If you post to an ASP.NET page or handler using this code, Request.Form("myValue") would work the same way as if an HTML form had been posted.

Categories