Does anyone check the domain of an email address as part of their verification steps? eg. Confirm that gmail.com exists if the user specified [email protected] as their address.
Hello!
I start to look at Node.js. Aslo I'm using Express.
And I have a question - how can I organize web application routes? All examples just put all this app.get/post/put() handlers in app.js and it works just fine. This is good but if I have something more than simple HW Blog? Is it possible to do something like this:
var app = express.createServer();
app.get( '/module-a/*', require('./module-a').urls );
app.get( '/module-b/*', require('./module-b').urls );
and
// file: module-a.js
urls.get('/:id', function(req, res){...}); // <- assuming this is handler for /module-a/1
In other words - I'd like something like Django's URLConf but in Node.js.
I am trying to configure Hudson to sent an email if a build fails to the person who committed the broken build to the SVN.
Question
Is it possible to do this and if so how do I configure Hudson to do it?
In routes.rb
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
but then
http://localhost:3000/foobars/alt
will work too. The params are:
{"action"=>"alt", "controller"=>"foobars"}
so looks like :id is optional here. How can you tell it is optional vs not optional? Can you make it so that it is not optional in routes.rb?
I'm building a CMS using WebForms on .NET 4.0 and have the following route that allows URLs like www.mysite.com/about to be mapped to the Page.aspx page, which looks up the dynamic content.
routes.MapPageRoute("page", "{name}", "~/Page.aspx");
The problem is that I have a couple of folders in my project that are interfering with possible URLs. For example, I have a folder called "blog" where I store pages related to handling blog functionality, but if someone creates a page for their site called "blog" then navigating to www.mysite.com/blog gets the following error:
403 - Forbidden: Access is denied. You
do not have permission to view this
directory or page using the
credentials that you supplied.
Other similar URLs route correctly, but I think because .NET is identifying /blog as a physical location on the server it is denying directory access. Is there a way to tell IIS / .NET to only look for physical files instead of files and folders?
I'm building a versioned API, so I have the following nested controllers:
ApiController < ApplicationController
Api::V1Controller < ApiController
Api::V1::EventsController < Api::V1Controller
The API is accessed via a subdomain. I have the following routes:
constraints(:subdomain => "api") do
scope :module => 'api' do
namespace :v1 do
resources :events
end
end
end
This produces the type of URL I want (/v1/events).
The problem I'm facing is when using responds_with in Api::V1::EventsController. Just doing something as simple as the below fails with the error too few arguments:
def index
@events = Event.all
respond_with(@events)
end
I know respond_width is meant to be used with resources, but I'm not sure how the events resource should be accessed from the constrained, scoped, and namespaced route. I can output other things (such as current_user), just not an array of events. Help?
In ASP.NET MVC is there an equivalent of the Html.ActionLink helper for Img tags?
I have a controller action that outputs a dynamically generated JPEG and I wanted to use the same Lambda expressions to link to it as I do HREFs using ActionLink.
Alternatively, a helper that just gives the URL to a route (again specified using Lambdas) would also be acceptable.
EDIT: I had originally specified that I was using Preview 5, however I see that a Beta has been released. So all-in-all the version number was an unneeded piece of info as I may be upgrading soon :-)
I want to develop an application that will automatically send an email as soon as an image is captured by the camera.
can anybody suggest some ideas regarding this???
Well the title isn't very descriptive but I'm not exactly sure how to explain but here goes!
I have a web application (can use either MVC or standard web forms) which a user signs in to. If the user has signed up for more than one product they will have the option to switch between them. For the sakes of this example lets say User1 signs in and has access to Product1, Product2 and Product3.
Now, each product will be very different and offer different functionally. What I want is the main view to be focused around the product they have selected and not redirected to a sub domain.
What I don't want to have to do is get them to go to www.mysite.com/product1 or www.mysite.com/product2 but simply www.mysite.com regardless of the product they have selected and have the site render the views etc for that product.
Wow does any of that make any sense? I was thinking mabe the use of sessions or something and URL rewriting? Are there any sample apps out there that make use of the same kind of functionallity that I could take a look at?
Thanks for any help I appreciate it!
Can't believe how difficult this seems to be all I want to is to validate a user inout using javascript to make sure that it is an email address. But can't get it to work:
I am using:
//validates a regulaer expression
Utilities2.prototype.validateEmail = function(stringToValidateArg)
{
alert('about to check regexp');
var regExpPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
alert(regExpPattern.test(stringToValidateArg));
}
But this always returns false, any ideas why is it because of the regular expression?
I've seen that IIS has a problem with letting colons into URLs. I also saw the suggestions others offered here.
With the site I'm working on, I want to be able to pass titles of movies, books, etc., into my URL, colon included, like this:
mysite.com/Movie/Bob:The Return
This would be consumed by my MovieController, for example, as a string and used further down the line.
I realize that a colon is not ideal. Does anyone have any other suggestions? As poor as it currently is, I'm doing a find-and-replace from all colons (:) to another character, then a backwards replace when I want to consume it on the Controller end.
validates_format_of :email,
:with => /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" + @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" + @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)/,
:message => "is missing or invalid"
Please let me know where is the problem? Is regular expression is wrong?
I'm using custom post types in WordPress 3.0 to manage 'courses' (or seminars, lectures, whatever term you'd prefer to have in mind).
Now for viewing a single 'course', the url structure is;
/course/course-name/
But for multiple courses?
/courses/category/category-name/
Or...
/course-category/category-name/
Or something entirely different?
I have the following URl:
http://localhost:12981/BaseEvent/EventOverview/12?type=Film
This is route:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
I want that in a browser the url looks like:
http://localhost:12981/Film/Overview/12
How can I do this?
One more example:
http://localhost:12981/BaseEvent/EventOverview/15?type=Sport
should be
http://localhost:12981/Sport/Overview/15
Thanks.
When i use only langRoute and moduleRoute i have not any problems. But when i add pageRoute it is not work properly. I have tried many another ways do it (Regex etc) but none gives the desired result. Can anybody help me?
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
//Route_page needs dispatcher and request
$dispatcher = $front->getDispatcher();
$request = $front->getRequest();
// Add languag routes
$langRoute = new Zend_Controller_Router_Route_Hostname(
':language.domain.com',
array(
'language' => 'ru',
),
array(
'language' => '^(ru|en)$',
)
);
// Add module routes
$moduleRoute = new Zend_Controller_Router_Route_Module(array(),$dispatcher,$request);
// Add page routes
$pageRoute = new Zend_Controller_Router_Route(
':uri\.html',
array(
'controller' => 'index',
'module' => 'default',
'action' => 'index',
'uri' => 'index',
),
array ('uri' => '[0-9a-z\-]+')
);
// Add chain routes
$chainedRoute = new Zend_Controller_Router_Route_Chain();
$chainedRoute->chain($pageRoute);
$chainedRoute->chain($langRoute)->chain($moduleRoute);
$router->addRoute('default', $chainedRoute);
This code below doesn't seem to work but i can't figure out why. If i have a user entered textbox that is a datepicker and the results are displayed as:
21-May-2010
, can i take this value and stick it into a URL to send over to a controller action so instead of an id (which is an int), i want a id which is a date value
View / Javascript Code:
$.get('/Tracker/DailyBlog/' + this.val(), function(data) {
$('#dailyblog').html(data);
});
ControllAction Code:
public ActionResult DailyBlog(DateTime blogDate)
{
//go do something
}
any idea why this is not working ?
I am trying to do a RedirectToAction from http://mywebsite/Home/ using the following code:
return RedirectToAction("Index","Profile", new { id = formValues["id"] });
The above code will succesfully take me to
http://mywebsite/Profile/Index/223224
What do I have to do to make it redirect to
http://mywebsite/Profile/223224
Thank you.
I figured out how to do this.
First I have to add custom route rule:
routes.MapRoute("Profile", "Profile/{id}", new { controller = "Profile", action = "Index", id = UrlParameter.Optional });
Then I can do the following:
[AcceptVerbs(HttpVerbs.Post)]
public RedirectResult Index(FormCollection formValues)
{
return Redirect("~/Survey/" + formValues["Id"]);
}
Hello All, I have the following classes:
Public Class Email
Private Shared ReadOnly EMAIL_REGEX = "\b[a-zA-Z]+[a-zA-Z0-9._+-]+@" + _
"[a-zA-Z0-9.-]+\.[a-zA-Z]{2,3}\b"
Private _email As String
Public Event emailCreated()
' Declare empty constructor private so the only way to create an object
' is using new (email)
Private Sub New()
End Sub
Sub New(ByVal email As String)
If Regex.IsMatch(email, EMAIL_REGEX) Then
_email = email
RaiseEvent emailCreated()
Else
Throw New Exception("Email Not Valid")
End If
End Sub
ReadOnly Property Email() As String
Get
Return _email
End Get
End Property
End Class
And
Public Class EmailForm
WithEvents myEmail As Email
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
myEmail = New Email(TextBox1.Text)
Catch ex As Exception
MessageBox.Show("Exception: " & ex.Message)
End Try
End Sub
Public Sub emailCreated() Handles myEmail.emailCreated
MessageBox.Show("New Email Created")
End Sub
End Class
If a create a wrong email lets say "email" the exception is correctly cached and a message is showed however is i input a valid email the event is not raised, the object is being created but no message is shown and no error or exception is thrown i suspect it has something to do with using "myemail = new Email(email)" but i have seen examples of using new with withevents with no problem.
I would apreciate any input about this problem
thank you
Hello!
I'm doing something very simple with mod_rewrite and it's behaving strange. It's behaving as if I'm using the [R] option, but I'm not. Here's a simple test for a .htaccess file:
RewriteEngine on
RewriteRule ^page1$ page2
This should redirect a request for page1 to page2, but leave the URL in the web browser still pointing to page1. That doesn't happen though. It actually switches the URL to page2, as if I were using this code:
RewriteRule ^page1$ page2 [R]
Why's it doing that? That's not the default behavior. I'm using a pre-configured machine I got for EC2, so it's probably something in the apache configuration I'm not aware of. Googling has been futile. Help?
This is Apache 2.12 btw.
Hello,
is it possible to send notification emails when passenger error occurs? Something similar to the email sending by exception notifier when there is an error in Rails app.
I wonder because now we have no way to find out if someone hits an unexpected app spawner or other error (like memory limit etc.).
Thank you!
Hi folks,
really simple question here.
when I remove the default route, I returns an empty page to the browser :-
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Now before everyone starts shouting "that's because that's the default route to access all action methods, etc.." .. i know that.
My question is - what code / routes does the default framework try and call .. which makes that Default Route get used/kick in?
Why? I don't wish to make that my default route regex (don't ask why - this is some R&D) but I still need the main home page .. ie. Home/Index . If i try and just add that route, it doesn't get called and an empty page is returned.
So -- what does the framework try and call when a user doesn't provide any urls? It's like there's some secret default document stuff set up?
Cheers :)
I am creating a web app which uses jQuery to authenticate:
$.ajax({
url: "/session/create?format=json",
type: "GET",
dataType: "json",
cache: false,
username: $("#signin-email").val(),
password: $("#signin-password").val(),
success: function(data) {
if(data.success) {
success = true;
}
}
});
The problem is that the code only makes the AJAX-request when the username does not include things like an @, which is required in my app. Can anyone help me with how I can do this? I do not mind changing the back-end a little bit, but requiring users to have an @-less email is not an option.
Oh, my back-end is a Ruby-on-Rails app
I am trying to implement my custom route in ASP.net MVC 3 but I get this error:
The resource cannot be found.
global.asax
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"mycontroller", // Route name
"{controller}/{name}", // URL with parameters
new { controller = "MyController", action = "Search" } // Parameter defaults
);
}
MyController.cs
public class MyController : Controller
{
public ActionResult Search(string name)
{
return Content(name);
}
}
I am working on a rails application and added a simple login system according to a book.
I created the controller admin:
rails generate controller admin login logout index
It added the following routes to routes.db
get "admin/login"
get "admin/logout"
get "admin/index"
I can got to http://localhost:3000/admin/login there is no problem at all.
But when I try to login I get: No route matches "/admin/login"!
Now, the first confusing part is that the "login" method of my AdminController is not executed at all.
The second confusing part is that this code works like a charm - redirects everything to /admin/login:
def authorize
unless User.find_by_id(session[:user_id])
flash[:notice] = "you need to login"
redirect_to :controller => 'admin', :action => 'login'
end
end
Sidenotes:
I restarted the server several times.
I tried a different browser - to be sure there is no caching problem.