How can I get this code working?
public ActionResult ABC(DateTime.Now.Ticks Id)
{
//some stuff
return View();
}
Your thoughts?
EDIT The whole concept is have unique URLs for each and every visitor/user.
First, the basics: when declaring a method, you need to specify the type of the parameter, which in this case would be long
:
public ActionResult Abc(long id)
{
// ...
}
When you call that (whether internally or whether it's responding to a URL, e.g. generated in Javascript), you can choose to use DateTime.Now.Ticks
as the argument to do, just as you could call the method like this inside the application:
Foo.Abc(DateTime.Now.Ticks);
However some warnings:
DateTime.UtcNow.Ticks
will return the same value multiple times when called in quick successionIf your idea is to generate a unique ID, I'd probably just go with Guid.NewGuid()
... or whatever your storage layer provides for generating unique IDs. Even keeping an internal, atomically-incremented counter on the machine has problems in terms of scaling horizontally. That's sometimes solved using a high-low ID generation strategy.
See more on this question at Stackoverflow