mainhandler.h

来自「Vc.Net入门与提高源码」· C头文件 代码 · 共 52 行

H
52
字号
// MainHandler.h : Defines the ATL Server request handler class
// (c) 2000 Microsoft Corporation
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Classes Reference and related electronic
// documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft C++ Libraries products.

#pragma once

// class CMainHandler
// This handler just validates the session and displays the user's first and last name 
// from the session cookie.
[ request_handler("Default") ]
class CMainHandler : public CMantaWebBase<CMainHandler>
{
public:
	HTTP_CODE ValidateAndExchange()
	{
		// Validate the session
		if (!ValidateSession())
			return ValidationError();

		return HTTP_SUCCESS;
	}

	[ tag_name("FirstName") ]
	HTTP_CODE OnFirstName()
	{
		// Respond with the first name from the session cookie
		LPCSTR lpszFirstName = GetFirstName();
		if (lpszFirstName)
			m_HttpResponse << lpszFirstName;
		else
			m_HttpResponse << "[first name unknown]";
		return HTTP_SUCCESS;
	}

	[ tag_name("LastName") ]
	HTTP_CODE OnLastName()
	{
		// Respond with the last name from the session cookie
		LPCSTR lpszLastName = GetLastName();
		if (lpszLastName)
			m_HttpResponse << lpszLastName;
		else
			m_HttpResponse << "[last name unknown]";
		return HTTP_SUCCESS;
	}
};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?