Controller without view page is not working RRS feed

  • Question

  • User1868852945 posted

    To send email I want to call a Controller that just sends the email and returns a string rather than invoking a view page.
    At first, just to get the send email to execute, I call the Controller from a link on another page.

    The error I get upon clicking on the link:

    The resource cannot be found.
    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
    Requested URL: /SendEmail/SendEmail

    The link:
    window.open("/SendEmail/SendEmail?p_db_type=ss", "tab_test");

    Controller class:
    namespace SchemaTrack.Controllers
    public class SendEmailController : Controller
    private string s = "debug stop";
    public String Index(string p_db_type)
    SendEmailRepository sendEmailRepo = new SendEmailRepository();
    sendEmailRepo.db_type = p_db_type;
    return "Email has been sent.";

    In debug I prove that the private string s gets reached ok. The error occurs right after clicking continue.
    Why am I getting the 404 error? I have tried many combinations and can't get past the 404.
    Thanks much if you can advise.

    Thursday, January 10, 2019 5:52 PM


  • User475983607 posted

    The 404 (Not Found) is correct!  The url points to a nonexistent SendEmail action.

    window.open("/SendEmail/SendEmail?p_db_type=ss", "tab_test");

    the correct URL is...

    window.open("/SendEmail/Index?p_db_type=ss", "tab_test");

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 10, 2019 5:57 PM